伊谢尔伦2017-04-17 16:04:19
查看服务器监听的端口:
$ 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 *:*
查看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)
你可以使用lsof查看端口被哪个服务占用了,然后停用那个服务就好了。
如果没有lsof命令,可以使用apt-get安装,
$ sudo apt-get install lsof
查找PID的方式建议用ps
命令
$ 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
是让程序保存当前数据后慢慢关闭