nginx version: nginx/1.8.0

I am trying to stop nginx with the following command /etc/init.d/nginx stop, however it is not returning any successful message. Then I tried to view the nginx processes with this command [![pidof nginx][1]][1] and it returns following pids 58058 58057.

My first query is why nginx is not stopping?

Another thing which I tried is to kill the processes, so as above mentioned PIDs I tried to remove them by following command kill 58058 & kill 58057, the processes are kill but amazingly new processes created automatically. When I again checked the with the command pidof nginx, this time it returns 2 more new processes 58763 58762.

My Second query is how these processes are automatically being created?

I know following query is off topic, however I also want to make changes to the configuration file under sites-available. Is there any way the config file changes will be implemented without restarting nginx server? (For this reason I am restarting my nginx) as we generally do with nginx.conf file with this command service nginx reload or /etc/init.d/nginx reload.

My configurations files with pastebin link are as following

  1. /etc/init/nginx.conf
  2. /etc/init.d/nginx
  3. /etc/nginx/nginx.conf
  4. php5/fpm/pool.d/www.conf
root@BS-Web-02:/var/run# cat nginx.pid 
root@BS-Web-02:/var/run# pidof nginx
58763 58762
root@BS-Web-02:/var/run# kill 58762
root@BS-Web-02:/var/run# pidof nginx
3809 3808
root@BS-Web-02:/var/run# cat nginx.pid 

Tried Following Solutions but didn't work

  1. Why doesn't stopping the nginx server kill the processes associated with it?
  2. Not able to stop nginx server

P.S I am using Varnish on Port 80 and nginx on 8080

  • File /var/run/nginx.pid is exist? Which PID it contains?
    – strangeman
    Sep 9 '15 at 6:17
  • @strangeman I have added the screenshot of the PIDs Sep 9 '15 at 7:36
  • @SukhjinderSingh prefer to Paste terminal contents rather than adding screenshot.
    – TPS
    Sep 9 '15 at 8:05
  • 1
    @Tejas added as per your request. Sep 9 '15 at 10:34

Check monit service for nginx configuration in /etc/monit.d/.

If it doesn't work, please post your data from /var/log/messages.

  • How this will tell me why my nginx not stopping and why it is creating new processes every time I kill them? Sep 9 '15 at 10:35
  • The Monit application uses PID file checks to see if an application is still running or not. That implies that a PID file must be available for an application, otherwise monit cannot guard it. If a daemon does not create a PID file, use a wrapper to create one. wiki.gentoo.org/wiki/…
    – XakRu
    Sep 9 '15 at 10:47
  • if you have monit, configured for nginx - at time when you will stop nginx, monit will start nginx automaticaly.
    – XakRu
    Sep 9 '15 at 10:48
  • Pls, show your /var/log/messages file
    – XakRu
    Sep 9 '15 at 10:49
  • Can please provide any link how to setup monit on Ubuntu 14. Unfortunately the logs are empty this was the reason I need to restart the server after adding access_log on. Sep 9 '15 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.