sudo service nginx stopI get this error:
$ sudo service nginx stop * Stopping Nginx Server... [fail]How do I fix it?
I am running Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-43-generic x86_64). At the time of the writing the Nginx init.d Ubuntu script version is 3.9.0.
A related article is I cannot kill Nginx with Unix kill command. How do I kill it without rebooting?
The reason this is happening might be because the Nginx's process ID's location specified by the new init script is different from the one specified by the old init script. In my case, the old PID file location is:
/run/nginx.pidAnd the new PID file location is:
To find out the PID file location, look in the nginx init.d Ubuntu script.
When you run "sudo service nginx stop", your operating system actually deletes the process indicated by the PID file. Since your Nginx process is using the old PID file location, your new init script cannot delete the correct process.
1. Stop Nginx process. Suppose your old init script is located at /etc/init.d/nginx.original, then run this command:
sudo service nginx.original stopRun the following command to make sure Nginx processes are gone:
ps aux | grep nginx2. Go to Nginx configuration file (mine is located at /usr/local/nginx/conf/nginx.conf) and change the following line:
pid /run/nginx.pid;To this line:
pid /usr/local/nginx/logs/nginx.pid;3. Start Nginx again by running the following command and this problem should be fixed:
sudo service nginx startQuestions? Let me know!