UPDATE March 28, 2016
I presented a small improvement to the Ubuntu Upstart script, which I proposed below, as a request for craving for the NGinX wiki. My transfer request was accepted and the patch was merged .
I am on Ubuntu 14.04 LTS and had the same problem; NginX can start normally with sudo service nginx restart , but it did not start automatically when the server started.
I followed the instructions on the NGinX Ubuntu Upstart Wiki page, but it did not work ( initially ). So I rummaged a bit. At first, I discovered that Ubuntu tried to start NGinX at startup, but failed:
$ sudo cat /var/log/boot.log ... * Starting nginx http daemon [fail] ...
Then I found the upstart initialization log file:
$ cat /var/log/upstart/nginx.log ... nginx: [emerg] host not found in upstream "<mydomain>:443" in /etc/nginx/sites-enabled/mydomain:2 ...
So, I realized that the launch of the NGINX script was started before the network interface was started. This server error response gave me the hints needed to fix the NginX Ubuntu Upstart script. Thus, '!', IFACE=lo must be changed to IFACE!=lo . For convenience, I inserted the full script below:
# nginx description "nginx http daemon" author "George Shammas <georgyo@gmail.com>" start on (filesystem and net-device-up IFACE!=lo) stop on runlevel [!2345] env DAEMON=/usr/sbin/nginx env PID=/var/run/nginx.pid expect fork respawn respawn limit 10 5
After rebooting, I checked if NGinX is running now:
$ sudo initctl list | grep nginx nginx start/running, process 1551
I will inform the author of this script about my findings.
Visionscaper
source share