nginx---进程开启、关闭和重载配置文件
2014-09-23 22:03
369 查看
环境:
centOS6.4 32位
原文地址:http://nginx.org/en/docs/control.html
启动进程
# /usr/local/nginx/sbin/nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# ps aux | grep nginx
root 6015 0.0 0.1 3472 516 ? Ss 14:34 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 6016 0.0 0.1 3656 864 ? S 14:34 0:00 nginx: worker process
root 6018 0.0 0.1 4356 732 pts/0 S+ 14:34 0:00 grep nginx
关闭进程
[root@localhost ~]# ps aux | grep nginx
root 6015 0.0 0.1 3472 516 ? Ss 14:34 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 6016 0.0 0.1 3656 864 ? S 14:34 0:00 nginx: worker process
root 6018 0.0 0.1 4356 732 pts/0 S+ 14:34 0:00 grep nginx
[root@localhost ~]# kill -QUIT 6015
[root@localhost ~]# ps aux | grep nginx
root 6020 0.0 0.1 4356 732 pts/0 S+ 14:37 0:00 grep nginx
在不关闭进程的情况下,重载配置文件
[root@localhost logs]# kill -HUP 6022
# cd /usr/local/nginx/logs
# ll
-rw-r--r--. 1 root root 2619 Sep 22 13:46 access.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 13:34 nginx.pid
# mv access.log access-111.log
# ll
-rw-r--r--. 1 root root 2619 Sep 22 13:46 access-111.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 13:34 nginx.pid
重新访问页面后
# ll
-rw-r--r--. 1 root root 4479 Sep 22 14:23 access-111.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 13:34 nginx.pid
访问日志名改变了,但还是继续写入了
重新启动服务或者重载配置文件以及使用USR1 都会新建日志文件
[root@localhost logs]# rm -rf access-111.log
[root@localhost logs]# ll
total 8
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:39 nginx.pid
[root@localhost logs]# kill -quit 6022
[root@localhost logs]# ps aux | grep nginx
root 6038 0.0 0.1 4356 732 pts/0 S+ 14:44 0:00 grep nginx
[root@localhost nginx]# ./sbin/nginx
[root@localhost nginx]# ps aux | grep nginx
root 6041 0.0 0.1 3472 516 ? Ss 14:44 0:00 nginx: master process ./sbin/nginx
nobody 6042 0.0 0.1 3656 864 ? S 14:44 0:00 nginx: worker process
root 6044 0.0 0.1 4356 732 pts/0 S+ 14:44 0:00 grep nginx
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 0 Sep 22 14:44 access.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# rm -rf logs/access.log
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# ps aux | grep nginx
root 6041 0.0 0.1 3472 516 ? Ss 14:44 0:00 nginx: master process ./sbin/nginx
nobody 6042 0.0 0.1 3656 864 ? S 14:44 0:00 nginx: worker process
root 6050 0.0 0.1 4356 728 pts/0 S+ 14:49 0:00 grep nginx
[root@localhost nginx]#
[root@localhost nginx]# kill -HUP 6041
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 0 Sep 22 14:50 access.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# rm -rf logs/access.log
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# kill -USR1 6041
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 nobody root 0 Sep 22 14:51 access.log
-rw-r--r--. 1 nobody root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
centOS6.4 32位
原文地址:http://nginx.org/en/docs/control.html
TERM, INT | fast shutdown |
QUIT | graceful shutdown 当请求处理完毕后才关闭进程 |
HUP | changing configuration, keeping up with a changed time zone (only for FreeBSD and Linux), starting new worker processes with a new configuration, graceful shutdown of old worker processes |
USR1 | re-opening log files |
USR2 | upgrading an executable file |
WINCH | graceful shutdown of worker processes |
# /usr/local/nginx/sbin/nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# ps aux | grep nginx
root 6015 0.0 0.1 3472 516 ? Ss 14:34 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 6016 0.0 0.1 3656 864 ? S 14:34 0:00 nginx: worker process
root 6018 0.0 0.1 4356 732 pts/0 S+ 14:34 0:00 grep nginx
关闭进程
[root@localhost ~]# ps aux | grep nginx
root 6015 0.0 0.1 3472 516 ? Ss 14:34 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 6016 0.0 0.1 3656 864 ? S 14:34 0:00 nginx: worker process
root 6018 0.0 0.1 4356 732 pts/0 S+ 14:34 0:00 grep nginx
[root@localhost ~]# kill -QUIT 6015
[root@localhost ~]# ps aux | grep nginx
root 6020 0.0 0.1 4356 732 pts/0 S+ 14:37 0:00 grep nginx
在不关闭进程的情况下,重载配置文件
[root@localhost logs]# kill -HUP 6022
# cd /usr/local/nginx/logs
# ll
-rw-r--r--. 1 root root 2619 Sep 22 13:46 access.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 13:34 nginx.pid
# mv access.log access-111.log
# ll
-rw-r--r--. 1 root root 2619 Sep 22 13:46 access-111.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 13:34 nginx.pid
重新访问页面后
# ll
-rw-r--r--. 1 root root 4479 Sep 22 14:23 access-111.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 13:34 nginx.pid
访问日志名改变了,但还是继续写入了
重新启动服务或者重载配置文件以及使用USR1 都会新建日志文件
[root@localhost logs]# rm -rf access-111.log
[root@localhost logs]# ll
total 8
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:39 nginx.pid
[root@localhost logs]# kill -quit 6022
[root@localhost logs]# ps aux | grep nginx
root 6038 0.0 0.1 4356 732 pts/0 S+ 14:44 0:00 grep nginx
[root@localhost nginx]# ./sbin/nginx
[root@localhost nginx]# ps aux | grep nginx
root 6041 0.0 0.1 3472 516 ? Ss 14:44 0:00 nginx: master process ./sbin/nginx
nobody 6042 0.0 0.1 3656 864 ? S 14:44 0:00 nginx: worker process
root 6044 0.0 0.1 4356 732 pts/0 S+ 14:44 0:00 grep nginx
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 0 Sep 22 14:44 access.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# rm -rf logs/access.log
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# ps aux | grep nginx
root 6041 0.0 0.1 3472 516 ? Ss 14:44 0:00 nginx: master process ./sbin/nginx
nobody 6042 0.0 0.1 3656 864 ? S 14:44 0:00 nginx: worker process
root 6050 0.0 0.1 4356 728 pts/0 S+ 14:49 0:00 grep nginx
[root@localhost nginx]#
[root@localhost nginx]# kill -HUP 6041
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 0 Sep 22 14:50 access.log
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# rm -rf logs/access.log
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 root root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
[root@localhost nginx]# kill -USR1 6041
[root@localhost nginx]# ll logs/
total 8
-rw-r--r--. 1 nobody root 0 Sep 22 14:51 access.log
-rw-r--r--. 1 nobody root 224 Sep 22 13:35 error.log
-rw-r--r--. 1 root root 5 Sep 22 14:44 nginx.pid
相关文章推荐
- Nginx开启关闭文件目录显示方法
- ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数。 worke
- Nginx启动后的进程与配置文件格式
- nginx-启动|关闭|重新加载配置文件的命令
- nginx重载配置文件及平滑升级
- ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数。 worke
- Nginx - 进程及配置文件
- 详解Nginx服务器的配置中开启文件Gzip压缩的方法
- 批量修改配置文件和批量关闭开启tomcat
- linux,Centos 6.3 yum安装Nginx+php+Mysql,配置防火墙,开启,关闭端口命令
- Nginx配置文件基本应用参考手册
- nginx配置文件详解
- centos nginx默认配置文件
- magento -- 修改文件来手动控制编译的开启和关闭
- nginx配置文件详解
- 系统“文件保护”的开启、关闭、应用方法
- Nginx配置文件中文注释详解
- nginx配置文件祥解
- nginx安装、配置(附配置文件)
- RHCE课程-RH033Linux基础笔记六之编辑工具VIM、网络配置、进程优先、日志文件简介(上)