1. 程式人生 > >CentOS7.2下Nginx的使用

CentOS7.2下Nginx的使用

syntax nginx配置 nginx的啟動 centos7 hup restart div -h star

Nginx的啟動

指定配置文件的方式啟動

nginx -c /etc/nginx/nginx.conf

對於yum安裝的nginx,使用systemctl命令啟動
systemctl start nginx

Nginx的停止

查詢Nginx的進程

ps -ef|grep nginx

從容停止

kill -QUIT Nginx主進程號

快速停止Nginx

kill -TERM Nginx主進程號

強制停止所有nginx進程

pkill -9 nginx

對於yum安裝的nginx,使用systemctl命令停止

systemctl stop nginx

Nginx的平滑重啟

在修改了nginx配置文件後,在重啟nginx之前,需要確認nginx配置文件的語法是否正確,可執行以下命令檢測

nginx -t -c /etc/nginx/nginx.conf

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

當顯示測試成功時,就可以平滑重啟了

nginx -s reload或者kill -HUP Nginx主進程號

對於yum安裝的nginx,使用systemctl命令重啟

systemctl restart nginx

CentOS7.2下Nginx的使用