Start Stop script for Nginx

0 Flares 0 Flares ×

In my earlier post I have described about how to compile and install nginx. Today in this post I will provide the start stop shell script for nginx. You can use this script to start and stop your Nginx. Also you can use this script to run nginx as a Linux service.You can download the script here, Download. Below are the available options for the script:


1. Start
2. Stop
3. Restart
4. Status
5. Reload etc.






Conventions Made Here: Here we have considered that your nginx installation directory is /usr/bin/nginx. If your Nginx installation directory is other than /usr/bin/nginx, then you need to replace all /usr/bin/nginx with your Nginx installation directory in the script.


Note: Before installing the script, if Nginx is already running then kill the process and proceed to install the script.



Instruction to install the script:



1. Login to the system as root user
2. Download the script and copy it to /etc/init.d/ location. Remember the script name should not be changed (It should be nginx without any file extension)
3. Change the file permission as Executable. You can give it 755.
4. That’s all, your script is installed.


How to use/How to start stop:



You can use the below commands from the shell:
1. To start: service nginx start
2. To Stop: service nginx stop
3. To Restart: service nginx restart
4. Available commands: service nginx help



That’s all. Now your script is completely installed and you can use it like a normal Linux service.

Nginx Start Stop Script




I am technical person. I deal with software development and services. I like to find new technologies and share new technical updates with all.

You may also like...

2 Responses

  1. ravi kumar singh says:

    It gives me error that that ” env: /etc/init.d/nginx: No such file or directory

    But i can the nginx file is there wit 755 permission . appreciate any help

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 0 Flares ×