ERROR : invalid PID number "" in "/run/nginx.pid"
Trying to run nginx -s reload
without first starting nginx will result in an error because nginx will look for the file containing it's master pid when you tell it to restart. In your case it seems that nginx wasn't running, so the file containing that id doesn't exist.
By running kill -9 25057
you tried to kill your own command ps -ef | grep nginx
which no longer existed, so you got "No such process".
To make sure all is well I would stop nginx with nginx -s stop
then start it with nginx
followed by nginx -s reload
to check that all is well. In any case the log file might tell you if something bad is going on /var/log/nginx/error.log
.
If that works, you can try accessing http://localhost:80 or however you have configured nginx, and also follow the error log, and access log /var/log/nginx/error.log
As a sidenote: If this by any chance happens to be a case where nginx is reloaded by some other tool like confd, you should also check if nginx actually stores it's pid in /run/nginx.pid
as opposed to /var/run/nginx/nginx.pid
.
Let's talk about what we have here first:
$ nginx -s reload2016/03/23 16:11:27 [error] 24992#0: invalid PID number "" in "/run/nginx.pid"
It's probably because the /run/nginx.pid
file is empty, that causes issues with stop|start|restart commands, so you have to edit it by sudo and put there PID of your current running nginx service (master process). Now, let's have a look at the next lines, which are connected with.
$ ps -ef | grep nginxroot 25057 2840 0 16:16 pts/1 00:00:00 grep --color=auto nginx$ kill -9 25057bash: kill: (25057) - No such process
You're trying here to kill NOT a main process of the nginx. First try to run the following command to see the pids of an nginx master process and his worker:
$ ps -aux | grep "nginx"root 17711 0.0 0.3 126416 6632 ? Ss 18:29 0:00 nginx: master process nginx -c /etc/nginx/nginx.confwww-data 17857 0.0 0.2 126732 5588 ? S 18:32 0:00 nginx: worker processubuntu 18264 0.0 0.0 12916 984 pts/0 S+ 18:51 0:00 grep --color=auto nginx
Next, kill both:
$ sudo kill -9 17711$ sudo kill -9 17857
and then try to run an nginx again.
$ service nginx startNothing..
Have nothing to say here ;)
Summary:
I think editing the /run/nginx.pid
file with an nginx master process PID should solve the issue. So according to my example above, this file should looks like this:
17711
Hope that helps!