Tag Archives: service

nginx startup script problems? Well! No More!

If you have messed with your nginx setup; perhaps you’ve installed it using yum and then you have come to a conclusion that you need passenger for a rails application and therefore you’ve built it again using source; you most probably have a corrupted nginx service control script now!
Well, no worries! You can fix it really easy.
1. use the “-V” switch of nginx to determine its configuration. something like
nginx -V

2. use “whereis” command to find possible locations of nginx executable. like
whereis nginx

3. to make sure you’ve stopped nginx, you can use a combination of “kill” and “pidof” commands. like
kill `pidof nginx`
Please note that I’m using ” ` ” and not ” ‘ “.

4. use a text editor like “vi” to edit the service control script.. it must be in an address like this: “\etc\init.d\nginx”. You may want to use “cp” to keep a copy of this file before you mess with it.
cp \etc\init.d\nginx \etc\init.d\nginx_original
and then
vi \etc\init.d\nginx

5. There should be lines where you can see the script decides where to look for conffile, pidfile and lockfile. edit them as per what you received from that “nginx -V” command

… and you’re finally good to go!
service nginx stop
service nginx start
service nginx status

These all should work now!