nginx: [emerg] bind() to 0.0.0.0:66 failed (98: Address already in use)

查看80端口,如果有进程直接kill杀死
root@ubuntu:/usr/local/nginx/sbin# netstat -ntlp|grep 80
root@ubuntu:/usr/local/nginx/sbin#
#检查Nginx配置
root@ubuntu:/usr/local/nginx# ./sbin/nginx -t -c ./conf/nginx.conf
nginx: the configuration file /usr/local/nginx/./conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/./conf/nginx.conf test is successful

#不依靠残留进程,重新启动Nginx
root@ubuntu:/usr/local/nginx# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx: [emerg] bind() to 0.0.0.0:66 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:66 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:66 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:66 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:66 failed (98: Address already in use)
nginx: [emerg] still could not bind()

#强制性杀死进程
root@ubuntu:/usr/local/nginx# pkill -9 nginx
root@ubuntu:/usr/local/nginx# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

#查看系统日志
root@ubuntu:/usr/local/nginx# journalctl -xe

Oct 08 02:01:37 ubuntu systemd[1]: Reloading.
Oct 08 02:01:37 ubuntu systemd[1]: Reloading.
Oct 08 02:01:37 ubuntu systemd[1]: Reloading.
Oct 08 02:05:02 ubuntu CRON[5289]: pam_unix(cron:session): session opened for user root by (uid=0)
Oct 08 02:05:02 ubuntu CRON[5290]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Oct 08 02:05:02 ubuntu CRON[5289]: pam_unix(cron:session): session closed for user root
Oct 08 02:06:20 ubuntu dhclient[52158]: DHCPREQUEST of 192.168.121.128 on ens33 to 192.168.121.254 port 67 (xid=0x3360b9fd)
Oct 08 02:06:20 ubuntu dhclient[52158]: DHCPACK of 192.168.121.128 from 192.168.121.254
Oct 08 02:06:20 ubuntu dhclient[52158]: bound to 192.168.121.128 – renewal in 896 seconds.
Oct 08 02:09:01 ubuntu CRON[5449]: pam_unix(cron:session): session opened for user root by (uid=0)
Oct 08 02:09:01 ubuntu CRON[5450]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean)
Oct 08 02:09:03 ubuntu CRON[5449]: pam_unix(cron:session): session closed for user root
Oct 08 02:15:01 ubuntu CRON[5559]: pam_unix(cron:session): session opened for user root by (uid=0)
Oct 08 02:15:01 ubuntu CRON[5560]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Oct 08 02:15:01 ubuntu CRON[5559]: pam_unix(cron:session): session closed for user root
Oct 08 02:17:01 ubuntu CRON[11067]: pam_unix(cron:session): session opened for user root by (uid=0)
Oct 08 02:17:01 ubuntu CRON[11068]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Oct 08 02:17:01 ubuntu CRON[11067]: pam_unix(cron:session): session closed for user root
Oct 08 02:17:06 ubuntu sudo[11070]: root : TTY=pts/0 ; PWD=/usr/local/nginx ; USER=root ; COMMAND=/bin/systemctl enable nginx.service
Oct 08 02:17:06 ubuntu sudo[11070]: pam_unix(sudo:session): session opened for user root by wzq(uid=0)
Oct 08 02:17:06 ubuntu sudo[11070]: pam_unix(sudo:session): session closed for user root
Oct 08 02:17:20 ubuntu sudo[11076]: root : TTY=pts/0 ; PWD=/usr/local/nginx ; USER=root ; COMMAND=/bin/systemctl status nginx.service
Oct 08 02:17:20 ubuntu sudo[11076]: pam_unix(sudo:session): session opened for user root by wzq(uid=0)
Oct 08 02:17:20 ubuntu sudo[11076]: pam_unix(sudo:session): session closed for user root
Oct 08 02:21:16 ubuntu dhclient[52158]: DHCPREQUEST of 192.168.121.128 on ens33 to 192.168.121.254 port 67 (xid=0x3360b9fd)
Oct 08 02:21:16 ubuntu dhclient[52158]: DHCPACK of 192.168.121.128 from 192.168.121.254
Oct 08 02:21:16 ubuntu dhclient[52158]: bound to 192.168.121.128 – renewal in 705 seconds.
Oct 08 02:25:01 ubuntu CRON[11201]: pam_unix(cron:session): session opened for user root by (uid=0)
Oct 08 02:25:01 ubuntu CRON[11202]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Oct 08 02:25:01 ubuntu CRON[11201]: pam_unix(cron:session): session closed for user root
Oct 08 02:26:25 ubuntu sudo[11217]: root : TTY=pts/0 ; PWD=/usr/local/nginx ; USER=root ; COMMAND=/usr/local/nginx/sbin/nginx
Oct 08 02:26:25 ubuntu sudo[11217]: pam_unix(sudo:session): session opened for user root by wzq(uid=0)
Oct 08 02:26:28 ubuntu sudo[11217]: pam_unix(sudo:session): session closed for user root
Oct 08 02:26:34 ubuntu sudo[11223]: root : TTY=pts/0 ; PWD=/usr/local/nginx ; USER=root ; COMMAND=/usr/local/nginx/sbin/nginx restart
Oct 08 02:26:34 ubuntu sudo[11223]: pam_unix(sudo:session): session opened for user root by wzq(uid=0)
Oct 08 02:26:34 ubuntu sudo[11223]: pam_unix(sudo:session): session closed for user root
Oct 08 02:33:01 ubuntu dhclient[52158]: DHCPREQUEST of 192.168.121.128 on ens33 to 192.168.121.254 port 67 (xid=0x3360b9fd)
Oct 08 02:33:01 ubuntu dhclient[52158]: DHCPACK of 192.168.121.128 from 192.168.121.254
Oct 08 02:33:01 ubuntu dhclient[52158]: bound to 192.168.121.128 – renewal in 826 seconds.
在这里插入图片描述

#-lt 列出监听的TCP端口, -u 或 --udp 显示UDP传输协议的连线状况,-n 输出中不解析主机、端口、名称, -p 显示进程ID和名称
root@ubuntu:/usr/local/nginx# netstat -ltunp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 4784/sshd
tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN 36359/postgres
tcp 0 0 0.0.0.0:66 0.0.0.0:* LISTEN 11291/nginx.conf
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 5178/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 76323/zabbix_server
tcp6 0 0 :::22 ::? LISTEN 4784/sshd
tcp6 0 0 :::88 ::? LISTEN 76404/apache2
tcp6 0 0 ::1:5433 ::? LISTEN 36359/postgres
tcp6 0 0 :::10050 ::? LISTEN 5178/zabbix_agentd
tcp6 0 0 :::10051 ::? LISTEN 76323/zabbix_server
udp 0 0 0.0.0.0:68 0.0.0.0:* 52158/dhclient
udp 0 0 0.0.0.0:53356 0.0.0.0:* 36547/snmpd
udp 0 0 127.0.0.1:161 0.0.0.0:* 36547/snmpd

#杀死指定PID的进程

[root@i-14fe7093 nginx]# kill 812

#检验进程是否杀死
在这里插入图片描述
#重启Nginx,此时没有残留进程占用80端口了

[root@ nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寰宇001

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值