Configuration files are fine.

root@maxserver:~# nginx -c /etc/nginx/nginx.conf -t** nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful 

When you try to re-read the config file writes this.

 root@maxserver:~# kill -HUP `cat /var/run/nginx.pid` -bash: kill: (5289) - No such process 

If you restart, it writes fail

 root@maxserver:~# sudo /etc/init.d/nginx restart * Restarting nginx nginx [fail] root@maxserver:~# 

What could be the reason? Why does he say that bash is no such process?

  • Well, if fail , it means it was not launched, and therefore No such process . You look at errors, it says it should be something wrong. You may have an Apache on the same port weighing, on which you are trying to start nginx. - BOPOH
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

When nginx terminates abnormally, it does not clear the pid in /var/run/nginx.pid , hence the process id remains, and the process itself has long died.

To see why nginx does not start, run in console from root

 $ nginx -c /etc/nginx/nginx.conf 

It will write to the same console why it cannot start.

If he writes

 nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use) 

That means someone has already taken this port, you can see who took it by executing the command

 $ netstat -apn | grep "0:80" 

Keys:

  -a :на всех интерфейсах машины -p :показывать PID и имя программы -n :показывать IP вместо резолва в хостнейм 

The output will be similar to the following:

 $ netstat -lapn | grep "0:80" tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2601/nginx 

The last column shows the PID / name of the process that uses the port.

Well, it is always useful to see the logs of nginx itself. They are by default in /var/log/nginx/error.log .