我使用此sh file安装Nginx。但是当我修改nginx.conf并尝试重新加载或重新启动Nginx时,它没有重新启动。此命令
sudo systemctl restart nginx
给我
sudo: unable to resolve host localhost.localdomain sudo: systemctl: command not found
和这一个
sudo service nginx restart
sudo: unable to resolve host localhost.localdomain nginx: unrecognized service
和这一个
sudo /etc/init.d/nginx restart
sudo: unable to resolve host localhost.localdomain sudo:
/etc/init.d/nginx: command not found
文件可能存在:/ usr / local / nginx / sbin / nginx确保您可以:
ps aux | grep nginx
杀死进程:
sudo killall nginx
然后重新开始:
/usr/local/nginx/sbin/nginx
可以使用以下任一命令行语法重新启动Nginx Web服务器。在基于系统的版本(例如Ubuntu Linux 16.04LTS及更高版本上,使用systemctl
:
sudo systemctl restart nginx
OR
sudo service nginx restart
OR(Ubuntu Linux的旧版本):
sudo /etc/init.d/nginx restart
相同的命令可用于启动/停止/重新启动Red Hat 7版本上的nginx服务器:
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
OR
sudo service nginx start
sudo service nginx stop
sudo service nginx restart
OR
sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart
查看Nginx服务器的状态,请使用以下任一命令:
sudo service nginx status
OR
sudo /etc/init.d/nginx status
对于Red Hat 7,CentOS 7和更高版本,为OR
sudo systemctl status nginx