解决Plesk面板Nginx不能自动启动的问题
问题描述:
禁用了Plesk的Nginx代理,单独使用Apache,因为在单独使用Apache的时候可以给每个网站设置带宽和连接数。重新启用Nginx代理之后,发现重启服务器之后,Nginx不能自动开机启懂,运行systemctl status nginx.service的时候出现如下的错误提示,但是可以通过systemctl start nginx.servie手动启动。
- [root@www ~]# systemctl status nginx.service
- ● nginx.service – Startup script for nginx service
- Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
- Active: failed (Result: exit-code) since 五 2018-01-12 21:19:58 CST; 25s ago
- 1月 12 21:19:57 www.ezloo.com systemd[1]: Starting Startup script for nginx service…
- 1月 12 21:19:58 www.ezloo.com nginx[844]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
- 1月 12 21:19:58 www.ezloo.com nginx[844]: nginx: [emerg] bind() to 172.31.191.115:443 failed (99: Cannot assign requested address)
- 1月 12 21:19:58 www.ezloo.com nginx[844]: nginx: configuration file /etc/nginx/nginx.conf test failed
- 1月 12 21:19:58 www.ezloo.com systemd[1]: nginx.service: control process exited, code=exited status=1
- 1月 12 21:19:58 www.ezloo.com systemd[1]: Failed to start Startup script for nginx service.
- 1月 12 21:19:58 www.ezloo.com systemd[1]: Unit nginx.service entered failed state.
- 1月 12 21:19:58 www.ezloo.com systemd[1]: nginx.service failed.
解决办法:
编辑 /etc/sysctl.conf,加入以下一行代码:
- # allow processes to bind to the non-local address
- net.ipv4.ip_nonlocal_bind = 1
再运行一下:
- sysctl -p /etc/sysctl.conf
重启服务器的时候,发现Nginx可以正常启动了。
解决Plesk面板Nginx不能自动启动的问题