Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx daemon stop is failing

I've got Ubuntu 11.04 i386 server with nginx 1.0.11 installed. Also, I'm using this init.d script, the only one I've found in several different places. It starts the server nicely, however, on stop/reset it says

* Stopping Nginx Server...      [fail]

Of course, the daemon is not stopped, and upon restart the configuration is not reloaded.

How can I repair this?

like image 653
Hubert OG Avatar asked Jan 13 '12 21:01

Hubert OG


People also ask

Why has Nginx stopped?

If Nginx notices a syntax error in any of the configuration files, the reload is aborted and the server keeps running based on old config files. Reloading is safer than restarting Nginx. The restart command will shut down the server including all related services and power it on again.

What is Nginx daemon off?

For Docker containers (or for debugging), the daemon off; directive tells Nginx to stay in the foreground. For containers this is useful as best practice is for one container = one process. One server (container) has only one service.

Where is Nginx PID located?

The process ID of the master process is written, by default, to the nginx. pid file, which is located in the /usr/local/nginx/logs or /var/run directory.


1 Answers

It's likely that it can't kill the process.

Open up the nginx sysvinit script located in /etc/init.d/ (or /etc/rc.d/) and find where nginx.pid is thought to be. It'll be something like "/var/run/nginx.pid".

If the pid file isn't there, open nginx.conf and look for the pid setting. If it is a mismatch - set the conf value to where the script thinks it should be, e.g.

# pid of nginx process
pid /var/run/nginx.pid;
like image 101
pragmar Avatar answered Sep 23 '22 15:09

pragmar