Start Stop script for Nginx
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:
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.