nginx使用service nginx restart报错

启动nginx服务时如果遇到这个错误 Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

可能原因:

1、配置文件语法有误,执行nginx -t

查看输出提示信息 并检查端口是否被占用netstat -tnlp

2、nginx的配置文件nginx.conf中监听了其他端口,这些端口的子进程仍然运行,导致端口占用。需要首先关闭子进程,才能使用该命令。

此时可以kill -9 pid 。

补充:

Linux环境Nginx命令

功能

sudo nginx -t

查看配置文件语法

sudo nginx -c /usr/local/nginx/conf/nginx.conf

指定配置文件启动

sudo nginx -s stop

强制停止nginx

sudo nginx -s reload

重新加载配置文件

sudo systemctl(或者service) start nginx

启动nginx

 sudo systemctl(或者service) enable nginx

开机自启动

sudo systemctl(service) restart nginx

重启nginx

 

更多推荐

启动nginx服务报错Job for nginx.service failed because the control process exited with