Home >Backend Development >PHP Tutorial >Stop and start nginx in linux environment

Stop and start nginx in linux environment

WBOY
WBOYOriginal
2016-07-29 09:14:501100browse

Step 1: Query nginx main process number

ps -ef | grep nginx
Find the master process in the process list. Its number is the main process number.

Step 2: Stop nginx

Stop Nginx gracefully:
kill -QUIT main process number
Stop Nginx quickly:
kill -TERM main process number
Force stop Nginx:
pkill -9 nginx

Step 3: Start nginx

Environment 1:
[root@iZ25yepqfvvZ /]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

[root@iZ25yepqfvvZ /]# ps -ef | grep nginx
root 18798 1 0 16:35 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
root 18799 18798 0 16:35 ? 00:00:00 nginx: worker process
root 18800 18798 0 16:35 ? 00:00:00 nginx: worker process
root 18801 18798 0 16:35 ? 00:00:00 nginx: worker process
root 18802 18798 0 16:35 ? 00:00:00 nginx: worker process
root 18827 15138 0 16:36 pts/1 00:00:00 grep nginx

environment 2
[root@iZ25yepqfvvZ /]# /usr/sbin/nginx -c /etc/nginx/nginx.conf

[root@iZ25knm9r1gZ ~]# ps -ef | grep nginx
root 28969 1 0 16:50 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 28970 28969 0 16:50 ? 00:00:00 nginx: worker process
nginx 28971 28969 0 16:50 ? 00:00:00 nginx: worker process
nginx 28972 28969 0 16:50 ? 00:00:00 nginx: worker process
nginx 28974 28969 0 16:50 ? 00:00:00 nginx: worker process
root 29419 29401 0 17:11 pts/0 00:00:00 grep nginx

The above introduces how to stop and start nginx in the Linux environment, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn