今天修改nginx配置文件,配置完了重启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.ps -ef | grep nginx
--显示所有含nginx的进程,然后一一kill掉。
2.pkill -9 nginx
--强制停止nginx服务
3.先试着执行了一下 nginx -t,返回
nginx: [emerg] BIO_new_file("/etc/nginx/cert/xxx.pem") failed
(SSL: error:02001002:system library:fopen:No such file or
directory:fopen('/etc/nginx/cert/xxx.pem','r')
error:2006D080:BIO routines:BIO_new_file:no such file)
看到这个我明白了,更改配置时把.pem和.key的路径改了,配置文件读取时所在的路径是nginx下而不是conf.d下,也就是说,cert这个文件夹要放在nginx下和conf.d平级。
再执行nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
成功了。再执行systemctl restart nginx,就没事了。