Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed the latest version of nginx (1.0.15) using apt-get from the source listed here:

For some reason, nginx isn't starting up automatically when I reboot the server, as I believe it should. /etc/init.d/nginx exists so I can start/stop/restart manually, but any ideas on why it isn't starting automatically? I was under the impression it should right out of the box if installed via apt-get.


Edit: After looking at various logs, I discovered that nginx wasn't starting on startup because I had an ssl server set up without a certificate (haven't added the certificate yet because I haven't yet migrated the domain). Commenting out the ssl server appears to have solved the problem. I presume that when I'm ready to add the certs for the domain the problem won't reappaer - here's hoping :).

As an aside, I was also experiencing a problem that the change above seems to have solved. I have Options -Indexes set in Apache to prevent directory browsing, and for most directory paths I would get the "Forbidden" message from Apache. For some, however, if I omitted the trailing slash in the path, the server wouldn't respond with the Forbidden message, or any message at all. I thought I must have some setting in nginx or apache2 that was causing this, but couldn't identify one. Now the problem has disappeared with the above change. Can't explain it.

share|improve this question
up vote 1 down vote accepted

The script in /etc/init.d doesn't actually do anything unless it's symlinked in /etc/rc2.d (or whatever the startup runlevel is).

To do this, run sudo update-rc.d nginx defaults which will create the necessary symlinks for automatically starting up the service after boot. You can verify by running ls -l /etc/rc?.d/*nginx before and after. The "after" will show symlinks to the script in /etc/init.d.

share|improve this answer
I did as you suggested and can verify the symlinks exist. But nginx still isn't starting on reboot. – user101570 Apr 17 '12 at 14:32
Does it start when you run /etc/ini.d/nginx start? Do you have Apache installed already, and it's starting up before nginx and sitting on port 80? – cjc Apr 17 '12 at 14:45
Yes, I'm able to execute /etc/init.d/nginx start|stop|restart with no problems. Just won't start on reboot. – user101570 Apr 17 '12 at 15:24
Anything in, say, /var/log/boot.log or /var/log/nginx during the boot? – cjc Apr 17 '12 at 15:26
Fixed. I'm accepting this answer for your suggestion to look at logs, and have edited my question to provide the solution. – user101570 Apr 19 '12 at 19:50

Try to add nginx script to be started at startup:

update-rc.d nginx defaults

share|improve this answer
Thanks, but didn't work. The symlinks exist but that hasn't solved the problem. – user101570 Apr 17 '12 at 14:33
What there in logs? If script won't start, you'll see the reason in both system log and nginx log. And please check if you're able to start nginx with exactly /etc/init.d/nginx start, so update-rc.d create right links. – Alexander Apr 17 '12 at 14:55
And have a look what's on 80/tcp port right after server reboot? If you have another http server (Apache or any other) then nginx can't bind to 80 port and won't work. Then you need to disable another http server. – Alexander Apr 17 '12 at 14:58
Hmm... I am using nginx as a reverse proxy to apache2, but apachd2 ports.conf is set to only listen on a different port from 80. – user101570 Apr 17 '12 at 15:13
Then it should work. What logs says, anyway? – Alexander Apr 17 '12 at 15:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.