Home > Net >  Nginx installed but command not found, how do I restart nginx
Nginx installed but command not found, how do I restart nginx

Time:06-22

I tried systemctl status nginx and got

 Unit nginx.service could not be found.

The server is currently running nginx

I use ps -ef | grep nginx and it returns info of nginx

root      6475  4292  0 16:58 pts/0    00:00:00 grep --color=auto nginx
nobody   31104 31334  0 Apr01 ?        00:00:13 nginx: worker process
root     31334     1  0 Jan25 ?        00:00:00 nginx: master process /usr/local/nginx-1.20.2/sbin/nginx -c /usr/local/nginx-1.20.2/conf/nginx.conf

how to restart this nginx?

CodePudding user response:

I found how to do it

ps -ef|grep nginx

find process of nginx

then kill all these process

then

/usr/local/nginx/sbin/nginx -c /usr/local/nginx-1.20.2/conf/nginx.conf

-c /usr/local/nginx-1.20.2/conf/nginx.conf is the config file option

CodePudding user response:

Seems, like you lost your nginx.service file (basically, located in /lib/systemd/system/nginx.service). Try to reinstall nginx:

sudo apt-get purge nginx nginx-common nginx-full  
sudo apt-get install nginx
  • Related