NGINX不在/ etc/default/nginx中应用变量

前端之家收集整理的这篇文章主要介绍了NGINX不在/ etc/default/nginx中应用变量前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我刚刚更新了我的一台服务器,从debian 6到debian 8.以前一切都运行正常.现在,Nginx无法以正确的配置启动.

我已将/ etc / default / Nginx设置为:

DAEMON_OPTS="-c /etc/Nginx/my.Nginx.file.conf"
DAEMON_ARGS=$DAEMON_OPTS

这应该使Nginx开始使用/etc/Nginx/my.Nginx.file.conf中设置的自定义配置文件而不是标准的/etc/Nginx/Nginx.conf.

我检查了init.d脚本,它有:

# Include Nginx defaults if available
if [ -r /etc/default/Nginx ]; then
        . /etc/default/Nginx
fi

但似乎并不适用.如果我删除文件/etc/Nginx/Nginx.conf并离开我的配置文件,我将得到以下内容

# /etc/init.d/Nginx start
[....] Starting Nginx (via systemctl): Nginx.serviceJob for Nginx.service Failed. See 'systemctl status Nginx.service' and 'journalctl -xn' for details.
 Failed!
# systemctl status Nginx.service
● Nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/Nginx.service; enabled)
   Active: Failed (Result: exit-code) since Fri 2016-04-22 14:35:14 UTC; 6s ago
  Process: 12772 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/Nginx.pid (code=exited,status=0/SUCCESS)
  Process: 3773 ExecReload=/usr/sbin/Nginx -g daemon on; master_process on; -s reload (code=exited,status=0/SUCCESS)
  Process: 12738 ExecStart=/usr/sbin/Nginx -g daemon on; master_process on; (code=exited,status=0/SUCCESS)
  Process: 5193 ExecStartPre=/usr/sbin/Nginx -t -q -g daemon on; master_process on; (code=exited,status=1/FAILURE)
 Main PID: 12740 (code=exited,status=0/SUCCESS)

Apr 22 14:35:14 xxx Nginx[5193]: Nginx: [emerg] open() "/etc/Nginx/Nginx.conf" Failed (2: No such file or directory)
Apr 22 14:35:14 xxx Nginx[5193]: Nginx: configuration file /etc/Nginx/Nginx.conf test Failed
Apr 22 14:35:14 xxx systemd[1]: Nginx.service: control process exited,code=exited status=1
Apr 22 14:35:14 xxx systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Apr 22 14:35:14 xxx systemd[1]: Unit Nginx.service entered Failed state.

如果我保留文件/etc/Nginx/Nginx.conf,Nginx将只是开始使用该文件而不是我自己的文件,即/etc/Nginx/my.Nginx.file.conf.我究竟做错了什么?

我试图避免编辑init.d脚本,如果可能的话.我知道我可以在那里设置DAEMON_OPTS.

最佳答案
你做错了是创建自己的/etc/Nginx/my.Nginx.file.conf而不是编辑/etc/Nginx/Nginx.conf.将文件放回标准位置.

Debian 8(最终)已移至systemd,不再使用旧的init脚本和/ etc / default / Nginx.当然,即使它们在使用中,这也是一个坏主意,但现在特别糟糕.

原文链接:https://www.f2er.com/nginx/435108.html

猜你在找的Nginx相关文章