How To Automatically Start Nginx & Fastcgi on Reboot on Fedora Linux

By Angsuman Chakraborty, Gaea News Network
Sunday, August 10, 2008

nginx [engine x] is a high quality, light footprint (much ligher than Apache HTTPD), high performance HTTP server and mail proxy server written by Igor Sysoev. nginx is distributed under BSD license unlike its competitor Lighttpd. We are progressively transferring our sites over to nginx. Today when I had to restart the server, I realized (after few hours) with horror that we had forgot to add the script to start nginx automatically after reboot. When you want any command to execute everytime after a reboot you should add it to /etc/rc.local. The commands in rc.local are executed *after* all the other init scripts. To automatically start nginx as well as fastcgi on reboot you should add the following lines to /etc/rc.local at the end -

/usr/bin/spawn-fcgi -a -p 9000 -u nginx  -g nginx -f /usr/bin/php-cgi -P /var/run/


  1. Change the port number as appropriate.
  2. The IP address may be changed if fastcgi is started on a different machine than from which it is accessed by nginx
  3. First verify the commands by executing them from console
  4. If nginx or spawn-fcgi is not available in the (default) location above then you can locate it with locate command like this:
    locate spawn-fcgi
  5. You should test your rc.local by actually rebooting the system and ensuring that fastcgi & nginx are actually started.

Another way to start nginx would be through service. However for that you will first need to create the init script in /etc/rc.d/init.d. Check out files like /etc/rc.d/init.d/network as an example.

Note: In Fedora Linux nginx init script (allowing you start, stop and restart using service and also auto-start on startup) is installed if you use the binary distribution.

August 25, 2008: 12:17 pm

if anyone would like a copy of my fedora 9 init.d script for this email me or just read up on this blog post to create your own.

will not be displayed