how can i change nginx Configuration file path
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?
/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
-c
flag 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 reload
Reload the
systemd
manager configuration :systemctl daemon-reload
-
Start
nginx
service :service nginx start
-
Check
nginx
service 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.