问题原文
原帖链接 · Rajkumar .E · CC BY-SA 3.0
i have installed nginx in ubuntu16.04, and check that Configuration file location is /etc/nginx/conf/nginx.conf
$ /usr/sbin/nginx -V 2>&1 | grep --colour=auto conf
then Show Configuration file path:
--conf-path=/etc/nginx/nginx.conf
I am working on Install openam nginx Webagent link, this nginx_agent have one nginx.conf file
nginx_web_agent install path:
/opt/nginx_agent
nginx_web_agent nginx.conf path:
/opt/nginx_agent/conf/nginx.conf
nginx_web_agent use that nginx.conf file,
How can i change nginx default nginx.conf file to nginx_web_agent nginx.conf file
for example:
nginx Configure use /opt/nginx_agent/conf/nginx.conf instead of /etc/nginx/nginx.conf
Suggest me How can i do that?
社区高分解答
原帖链接 · krisFR · CC BY-SA 3.0
/usr/sbin/nginx -V shows the initial configure script parameters, not necessarily the actual parameters that are running.
To use an alternative configuration file, instead on the default one, you can set the -c flag (man nginx) :
/usr/sbin/nginx -c /opt/nginx_agent/conf/nginx.conf
Ubuntu 16.04 uses systemd to manage services, so you will need to change systemd parameters for nginx service :
- Edit
/lib/systemd/system/nginx.service Add
-cflag where required :ExecStartPre=/usr/sbin/nginx -t -c /opt/nginx_agent/conf/nginx.conf -q -g 'daemon on; master_process on;' ExecStart=/usr/sbin/nginx -c /opt/nginx_agent/conf/nginx.conf -g 'daemon on; master_process on;' ExecReload=/usr/sbin/nginx -c /opt/nginx_agent/conf/nginx.conf -g 'daemon on; master_process on;' -s reloadReload the
systemdmanager configuration :systemctl daemon-reloadStart
nginxservice :service nginx startCheck
nginxservice parameters :systemctl status nginx.service ... 2411 nginx: master process /usr/sbin/nginx -c /opt/nginx_agent/conf/nginx.conf -g daemon on; master_process on ...
This is the way i would do it.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
