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

小白记录
在修改nginx配置时,用超级管理员运行报错

[root@localhost ~]# sudo /usr/sbin/nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

先查看端口被谁占用了

[root@localhost ~]# 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:80              0.0.0.0:*               LISTEN      7241/nginx: master  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      826/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1101/master         
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN      7080/uwsgi          
tcp6       0      0 :::22                   :::*                    LISTEN      826/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1101/master         
tcp6       0      0 :::3306                 :::*                    LISTEN      6310/mysqld         

不好意思,是我自己,然后关掉占用80端口的进程

yum install psmisc
sudo fuser -k 80/tcp

然后再用超级管理员运行,运行成功无报错,再查看nginx进程状态

sudo /usr/sbin/nginx
sudo service nginx restart
ps aux|grep nginx
发布了6 篇原创文章 · 获赞 0 · 访问量 85

猜你喜欢

转载自blog.csdn.net/qq_42091101/article/details/104137466