记一次 Mac 端口占用程序查找经历

需求

找到80端口占用程序,并关闭它

步骤

  • 网上教程通常提供的命令,出现的结果太杂(无效)
    netstat -vanp tcp | grep 80

  • 查找 80 端口被占用的程序进程(有效)
    sudo lsof -i tcp:80

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
httpd      93 root    4u  IPv6 0xb6f6a6b5914c0cff      0t0  TCP *:http (LISTEN)
httpd     926 _www    4u  IPv6 0xb6f6a6b5914c0cff      0t0  TCP *:http (LISTEN)
httpd   13401 _www    4u  IPv6 0xb6f6a6b5914c0cff      0t0  TCP *:http (LISTEN)
httpd   13402 _www    4u  IPv6 0xb6f6a6b5914c0cff      0t0  TCP *:http (LISTEN)
httpd   13403 _www    4u  IPv6 0xb6f6a6b5914c0cff      0t0  TCP *:http (LISTEN)

发现是 httpd 命令

  • ps axu | grep 926
➜  web-server-laravel git:(master) ps axu | grep 926
root             84108   0.0  0.0  4309264      8   ??  SNs  22Nov18   0:00.01 /usr/libexec/periodic-wrapper monthly
root             29064   0.0  0.0  4309264      8   ??  SNs   7Nov18   0:00.02 /usr/libexec/periodic-wrapper weekly
root             24733   0.0  0.0  4309264      8   ??  SNs   6Nov18   0:00.09 /usr/libexec/periodic-wrapper daily
_www               926   0.0  0.0  4334768    952   ??  S     6Nov18   0:00.06 /usr/sbin/httpd -D FOREGROUND
  • 停用 httpd 服务
    sudo apachectl stop

参考资料

  • webserver - How do I stop httpd running under Mac OS X (10.11) El Capitan Server? - Super User

你可能感兴趣的:(记一次 Mac 端口占用程序查找经历)