安装nginx后发现nginx启动不起来:
查看日志报错情况:
tail -1000f /var/log/nginx/error.log
2023/12/04 16:29:50 [notice] 8482#8482: try again to bind() after 500ms
2023/12/04 16:29:50 [emerg] 8482#8482: bind() to 0.0.0.0:80 failed (98: Address already in use)
2023/12/04 16:29:50 [notice] 8482#8482: try again to bind() after 500ms
2023/12/04 16:29:50 [emerg] 8482#8482: still could not bind()
看报错内容应该是服务已经启动,但端口不能用。nginx服务的端口是80,突然想到之前安装过httpd服务,而httpd服务也是用的80端口。查看一下:
可以通过关闭httpd服务或者杀掉占用80端口的进程解决:
systemctl stop httpd #关闭httpd服务
kill -9 952 #952是进程号
然后重启nginx服务:
systemctl restart nginx