description
systemctl restart nginx
nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) (thawing) since Sun 2021-09-12 00:58:03 CST; 7h ago
Docs: http://nginx.org/en/docs/
Process: 2049 ExecStop=/bin/sh -c /bin/kill -s TERM $(/bin/cat /var/run/nginx.pid) (code=exited, status=0/SUCCESS)
Process: 2054 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 2055 (nginx)
Tasks: 5 (limit: 98805)
Memory: 18.2M
CGroup: /system.slice/nginx.service
├─2055 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
├─2056 nginx: worker process
├─2057 nginx: worker process
├─2058 nginx: worker process
└─2059 nginx: worker process
Related
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/nginx.service.d
└─override.conf
Active: active (running) since Sat 2020-08-15 14:47:52 UTC; 26min ago
Process: 31083 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=2)
Process: 31096 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
Process: 31092 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 31087 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 31095 (nginx)
Tasks: 2
Memory: 6.9M
CPU: 3.635s
CGroup: /system.slice/nginx.service
├─31095 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
└─31098 nginx: worker process
Aug 15 14:47:52 ip-* * * * systemd[1]: nginx.service: Unit entered failed state.
Aug 15 14:47:52 ip- * * * * systemd[1]: nginx.service: Failed with result 'timeout'.
This is what it brings when you check nginx status
[root#ttproxyapp conf.d]# service nginx status
Redirecting to /bin/systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: inactive (dead)
sudo systemctl stop apache2
sudo systemctl start nginx
should work since looks like the port is in use (with apache probably)
It realy looks like your NGINX ins't running. nginx -s reload is just working if there is a running instance and therfore a PID-file.
Please check the result of the following command.
[root#localhost conf.d]# sudo ps -elf | grep nginx
Should be something like
1 S root 88262 1 0 80 0 - 13143 sigsus 23:47 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
5 S nginx 88263 88262 0 80 0 - 13257 ep_pol 23:47 ? 00:00:00 nginx: worker process
0 R root 88265 69227 0 80 0 - 28178 - 23:47 pts/1 00:00:00 grep --color=auto nginx
You need at least! the master process and the worker process! If there is no process start your instance by typing
sudo /bin/systemctl start nginx.service OR sudo service nginx start
Check your processlist after running the command.
After you have started the NGINX service there should be PID-file located at
/var/run/nginx.pid and sudo systemctl status nginx.service should printout something like
[root#localhost conf.d]# systemctl status nginx.service
● nginx.service - NGINX Plus - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-03-14 23:47:13 EDT; 5min ago
Docs: https://www.nginx.com/resources/
Process: 88232 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 88260 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Process: 88251 ExecStartPre=/usr/libexec/nginx-plus/check-subscription (code=exited, status=0/SUCCESS)
Main PID: 88262 (nginx)
Tasks: 2
Memory: 1.7M
CGroup: /system.slice/nginx.service
├─88262 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─88263 nginx: worker process
Mar 14 23:47:13 localhost.localdomain systemd[1]: Starting NGINX Plus - high performance web server...
Mar 14 23:47:13 localhost.localdomain systemd[1]: Can't open PID file /var/run/nginx.pid (yet?) after start: No such file or directory
Mar 14 23:47:13 localhost.localdomain systemd[1]: Started NGINX Plus - high performance web server.
I am running NGINX Plus but it doesn't matter in this case.
there is maybe an apache server running. you must stop that apache server order run the Nginx server.
sudo systemctl stop apache2
sudo systemctl start nginx
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: timeout) since Tue 2020-03-10 16:35:07 UTC; 9min ago
Process: 5027 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 5023 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 5021 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 25158 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nginx.service
├─5029 nginx: master process /usr/sbin/nginx
├─5030 nginx: worker process
├─5031 nginx: worker process
├─5032 nginx: worker process
├─5033 nginx: worker process
├─5034 nginx: worker process
├─5035 nginx: worker process
├─5036 nginx: worker process
├─5037 nginx: worker process
├─5038 nginx: worker process
├─5039 nginx: worker process
├─5040 nginx: worker process
├─5041 nginx: worker process
├─5042 nginx: worker process
├─5043 nginx: worker process
├─5044 nginx: worker process
├─5045 nginx: worker process
├─5046 nginx: worker process
├─5047 nginx: worker process
├─5048 nginx: worker process
├─5049 nginx: worker process
├─5050 nginx: worker process
├─5051 nginx: worker process
├─5052 nginx: worker process
└─5053 nginx: worker process
Mar 10 16:33:37 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: Starting The nginx HTTP and reverse proxy server...
Mar 10 16:33:37 ip-172-31-36-184.us-west-2.compute.internal nginx[5023]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Mar 10 16:33:37 ip-172-31-36-184.us-west-2.compute.internal nginx[5023]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Mar 10 16:33:37 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: PID file /run/nginx.pid not readable (yet?) after start.
Mar 10 16:35:07 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: nginx.service start operation timed out. Terminating.
Mar 10 16:35:07 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Mar 10 16:35:07 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: Unit nginx.service entered failed state.
Mar 10 16:35:07 ip-172-31-36-184.us-west-2.compute.internal systemd[1]: nginx.service failed.
I have such error and I don't know how to solve this problem.
I did all configurations but it still doesn't run.
This is the root cause of the issue
PID file /run/nginx.pid not readable (yet?) after start.
you may need to start the NGINX server with root privileges or update the service file to have the pid file in another location that is readable by Nginx
PIDFile=/usr/local/nginx/logs/nginx.pid
Today I was installing nginx with pterodactyl.io but It Is giving me errors and nginx can't start. Can you help me please?
root#Myserver:~# systemctl status nginx.service
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabl Active: failed (Result: exit-code) since Mon 2019-06-24 20:12:33 UTC; 17s ago
Docs: man:nginx(8)
Process: 23704 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --p Process: 23550 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=e Process: 23707 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on Main PID: 23553 (code=exited, status=0/SUCCESS)
Jun 24 20:12:33 Myserver systemd[1]: Stopped A high performance web server and a rJun 24 20:12:33 Myserver systemd[1]: Starting A high performance web server and a Jun 24 20:12:33 Myserver nginx[23707]: nginx: [emerg] BIO_new_file("/etc/letsencryJun 24 20:12:33 Myserver nginx[23707]: nginx: configuration file /etc/nginx/nginx.Jun 24 20:12:33 Myserver systemd[1]: nginx.service: Control process exited, code=eJun 24 20:12:33 Myserver systemd[1]: nginx.service: Failed with result 'exit-code'Jun 24 20:12:33 Myserver systemd[1]: Failed to start A high performance web serverlines 1-16/16 (END)
Thanks
I can't restart nginx server. the following error encountered. I suspect the cause could be that there's another service running on port 80.
I tried listing down all services running on port 80. But it does not show any.
root#ubuntu:/# sudo service nginx restart
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
root#ubuntu:/# systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-04-21 15:21:14 EDT; 53s ago
Docs: man:nginx(8)
Process: 121217 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run
Process: 120160 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, stat
Process: 121540 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exi
Main PID: 120162 (code=exited, status=0/SUCCESS)
Apr 21 15:21:13 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy s
Apr 21 15:21:14 ubuntu nginx[121540]: nginx: [emerg] "listen" directive is not allowed here in
Apr 21 15:21:14 ubuntu nginx[121540]: nginx: configuration file /etc/nginx/nginx.conf test fail
Apr 21 15:21:14 ubuntu systemd[1]: nginx.service: Control process exited, code=exited status=1
Apr 21 15:21:14 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'.
Apr 21 15:21:14 ubuntu systemd[1]: Failed to start A high performance web server and a reverse