解决nginx提示:(code=exited, status=203/EXEC)的错误
项目场景:在centos7上启动nginx1.19.安装过程省略...问题描述:编译安装一切顺利,使用systemctl start nginx时提示如下内容:[root@localhost stream_conf]# systemctl status nginx● nginx.service - nginx - web serverLoaded: loaded (/usr/lib/systemd
·
项目场景:
在centos7上启动nginx1.19.安装过程省略...问题描述:
编译安装一切顺利,使用systemctl start nginx时提示如下内容:
[root@localhost stream_conf]# systemctl status nginx
● nginx.service - nginx - web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 二 2021-12-14 14:58:49 CST; 36s ago
Process: 22970 ExecStartPre=/opt/server/nginx/sbin/nginx -t -c /opt/server/nginx/conf/nginx.conf (code=exited, status=203/EXEC)
12月 14 14:58:49 localhost.localdomain systemd[1]: Starting nginx - web server...
12月 14 14:58:49 localhost.localdomain systemd[22970]: Failed at step EXEC spawning /opt/server/nginx/sbin/nginx: No such file or directory
12月 14 14:58:49 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=203
12月 14 14:58:49 localhost.localdomain systemd[1]: Failed to start nginx - web server.
12月 14 14:58:49 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
12月 14 14:58:49 localhost.localdomain systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
重点报错内容:(code=exited, status=203/EXEC)
原因分析:
设置systemctl启动方式时出现配置文件(nginx.conf)的有效路径错误。
解决方案:
配置方法如下:
--先备份
[rot@localhost stream_conf]# cp /usr/lib/systemd/system/nginx.service /usr/lib/systemd/system/nginx.service.bak
--修改参数
[root@localhost stream_conf]# vim /usr/lib/systemd/system/nginx.service
--以下为原文件
[Unit]
Description=nginx - web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/server/nginx/conf/nginx.pid
ExecStartPre=/opt/server/nginx/sbin/nginx -t -c /opt/server/nginx/conf/nginx.conf
ExecStart=/opt/server/nginx/sbin/nginx -c /opt/server/nginx/conf/nginx.conf
ExecReload=/opt/server/nginx/sbin/nginx -s reload
ExecStop=/opt/server/nginx/sbin/nginx -s stop
ExecQuit=/opt/server/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
--修改为
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
--然后重启systemctl
[rot@localhost stream_conf]# systemctl daemon-reload
---尝试启动nginx
[root@localhost stream_conf]# systemctl start nginx
[root@localhost stream_conf]# systemctl status nginx
更多推荐
已为社区贡献2条内容
所有评论(0)