我在debian9上安装了nginx-full,但无法启动。当我这样做的时候。
sudo /etc/init.d/nginx start
我有
[....] Starting nginx (via systemctl): nginx.serviceJob for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
failed!
我也尝试过
sudo nginx -t
并且得到了
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
systemctl status nginx.service 的输出是:
$sudo systemctl status nginx.service
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-06-06 15:16:04 IST; 10min ago
Docs: man:nginx(8)
Process: 2305 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 2302 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 27844 (code=exited, status=0/SUCCESS)
Jun 06 15:16:02 debedx nginx[2305]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jun 06 15:16:02 debedx nginx[2305]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jun 06 15:16:03 debedx nginx[2305]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jun 06 15:16:03 debedx nginx[2305]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jun 06 15:16:04 debedx nginx[2305]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jun 06 15:16:04 debedx nginx[2305]: nginx: [emerg] still could not bind()
Jun 06 15:16:04 debedx systemd[1]: nginx.service: Control process exited, code=exited status=1
Jun 06 15:16:04 debedx systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jun 06 15:16:04 debedx systemd[1]: nginx.service: Unit entered failed state.
Jun 06 15:16:04 debedx systemd[1]: nginx.service: Failed with result 'exit-code'.
答案1
查看 的输出systemctl status nginx.service
,似乎运行 nginx 的端口正在被其他进程使用。
您可以使用netstat -tulpn|grep 80
命令进行检查。一旦确定,
(1) 更改端口号。通过使用编辑器进行编辑并设置并nginx
启动( )或/etc/nginx/nginx.conf
'Listen <new_port_no.>'
nginx
systemctl start nginx.service
(2) 如果该进程不重要,则通过发出命令和 start 来终止该进程nginx
。要了解进程的进程 ID,请键入:ps aux|grep <process name>
kill <process id>
在终止进程之前确定您要做什么。因此我建议您更改端口号。的nginx