search

Home  >  Q&A  >  body text

linux - 80端口被占用了吗

在启动apache的时候报错


感觉80端口被占用了

想把占用80端口的进程kell掉,下面的情况都找不到pid,是没被占用吗?

PHPzPHPz2903 days ago765

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 16:04:19

    View the port the server is listening on:

    $ ss -tunl
    Netid  State      Recv-Q Send-Q     Local Address:Port       Peer Address:Port 
    tcp    LISTEN     0      128                    *:6378                  *:*     
    tcp    LISTEN     0      128                   :::6378                 :::*     
    tcp    LISTEN     0      128                   :::80                   :::*     
    tcp    LISTEN     0      128                   :::22                   :::*     
    tcp    LISTEN     0      128                    *:22                    *:*     
    tcp    LISTEN     0      100                  ::1:25                   :::*     
    tcp    LISTEN     0      100            127.0.0.1:25                    *:*

    Check which program is occupying port 80

    $ lsof -i:80
    COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    httpd   2666   root    4u  IPv6  15095      0t0  TCP *:http (LISTEN)
    httpd   2668 apache    4u  IPv6  15095      0t0  TCP *:http (LISTEN)
    httpd   2669 apache    4u  IPv6  15095      0t0  TCP *:http (LISTEN)
    httpd   2670 apache    4u  IPv6  15095      0t0  TCP *:http (LISTEN)
    httpd   2671 apache    4u  IPv6  15095      0t0  TCP *:http (LISTEN)
    httpd   2672 apache    4u  IPv6  15095      0t0  TCP *:http (LISTEN)
    httpd   2673 apache    4u  IPv6  15095      0t0  TCP *:http (LISTEN)
    httpd   2674 apache    4u  IPv6  15095      0t0  TCP *:http (LISTEN)
    httpd   2675 apache    4u  IPv6  15095      0t0  TCP *:http (LISTEN)

    You can use lsof to check which service the port is occupied, and then disable that service.

    If you don’t have the lsof command, you can use apt-get to install it,

    $ sudo apt-get install lsof

    To find the PID, it is recommended to use the ps commandps命令

    $ ps aux | grep httpd
    root      2666  0.0  0.3 177344  3836 ?        Ss   14:31   0:00 /usr/sbin/httpd
    apache    2668  0.0  0.2 177344  2452 ?        S    14:31   0:00 /usr/sbin/httpd
    apache    2669  0.0  0.2 177344  2452 ?        S    14:31   0:00 /usr/sbin/httpd
    apache    2670  0.0  0.2 177344  2468 ?        S    14:31   0:00 /usr/sbin/httpd
    apache    2671  0.0  0.2 177344  2452 ?        S    14:31   0:00 /usr/sbin/httpd
    apache    2672  0.0  0.2 177344  2452 ?        S    14:31   0:00 /usr/sbin/httpd
    apache    2673  0.0  0.2 177344  2452 ?        S    14:31   0:00 /usr/sbin/httpd
    apache    2674  0.0  0.2 177344  2452 ?        S    14:31   0:00 /usr/sbin/httpd
    apache    2675  0.0  0.2 177344  2452 ?        S    14:31   0:00 /usr/sbin/httpd
    root      3469  0.0  0.0 103308   888 pts/4    S+   19:16   0:00 grep httpd
    $ sudo killall -9 $pid
    or
    $ sudo killall -15 $pid

    killall -9是强制杀死
    killall -15 rrreee

    killall -9 is a forced kill
    killall -15 is to let the program save the current data and then close slowly🎜

    reply
    0
  • Cancelreply