Welcome! Log In Create A New Profile

Advanced

How do I get nginx to use a different config file on boot?

Posted by guy 
guy
How do I get nginx to use a different config file on boot?
June 20, 2016 05:54PM
I posted this on askubuntu.com and someone told me that this is the best place to post so reposting here:

I'm trying to do something that I consider fairly simple... When Ubuntu boots, I want to start nginx using a config in a non-standard location (e.g. /home/ubuntu/foo/nginx.conf)

I've just installed that latest nginx (1.10.1) and I notice that it starts on boot and if I do "ps ax | grep nginx" I get a list of a bunch of worker process.

I haven't been able to find any standard way for it to not use its default config in /etc/nginx/nginx.conf

I could copy the contents of my .conf file into the standard .conf file and that would solve the problem. I don't what to do that because mine is in source control in its location and it will be updated now and then.

I was thinking of adding an @reboot entry to crontab to stop nginx and then start it with the -c param so that it would pickup my config. However that feels like the wrong solution. i.e. 1. allow Ubuntu to start nginx 2. shut it down 3. restart it with a different config.

Anyone know the answer to this?

(Ubuntu 14.04)
Re: How do I get nginx to use a different config file on boot?
June 20, 2016 06:26PM
nginx has a commandline option to tell where to load the config from.

-c /path/nginx.conf

---
nginx for Windows http://nginx-win.ecsds.eu/
guy
Re: How do I get nginx to use a different config file on boot?
June 20, 2016 07:01PM
So how do I get it to use that -c option when it starts when ubuntu boots up? i.e. where is the "meta-config" that tells nginx how to start?

If you look at my question you'll see the second option I was looking at is to restart nginx with that option using the crontab. That seems wrong though. I'm sure that nginx has a way to pass in the config at boot.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 116
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready