加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

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

发布时间:2020-12-13 21:09:03 所属栏目: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

我刚刚更新了我的一台服务器,从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.当然,即使它们在使用中,这也是一个坏主意,但现在特别糟糕.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读