nginx安装以及信号量

nginx安装
高性能web服务器
1.1下载
[root@localhost soft]# wget http://nginx.org/download/nginx-1.4.2.tar.gz
[root@localhost soft]# tar -zxf nginx-1.4.2.tar.gz
[root@localhost nginx-1.4.2]# yum install pcre   pcre-devel#rewrite模块使用
[root@localhost nginx-1.4.2]# ./configure --prefix=/usr/local/nginx
root@localhost nginx-1.4.2]# make && make install
[root@localhost nginx-1.4.2]# cd /usr/local/nginx
[root@localhost nginx]# ls
conf  配置文件
html 网页文件
logs  日志文件
sbin  进程文件
[root@localhost nginx]# ./sbin/nginx启动nginx
[root@localhost nginx]# ps aux|grep nginx
root      7686  0.0  0.0  20292   608 ?        Ss   02:56   0:00 nginx: master process ./sbin/nginx   ################master
nobody    7687  0.0  0.1  20688  1160 ?        S    02:56   0:00 nginx: worker process# worker
root      8228  0.0  0.0 103248   864 pts/0    S+   03:04   0:00 grep nginx

[root@localhost nginx]# kill -INT 7686
Nginx的信号控制
TERM, INT                       Quick shutdown
QUIT                           Graceful shutdown  优雅的关闭进程,即等请求结束后再关闭
HUP                               Configuration reload ,Start the new worker processes with
                               a new configuration Gracefully shutdown the old worker processes
                               改变配置文件,平滑的重读配置文件
USR1                           Reopen the log files 重读日志,在日志按月/日分割时有用
USR2                           Upgrade Executable on the fly 平滑的升级#版本升级用,比如说1.4升级到1.6覆盖安装nginx
WINCH                           Gracefully shutdown the worker processes 优雅关闭旧的进程(配合USR2来进行升级)


具体语法:
Kill -信号选项 nginx的主进程号

[root@localhost nginx]# vi conf/nginx.conf
location / {
            root   html;
            index ab.html  index.html index.htm;
        }
[root@localhost nginx]# vi html/ab.html

<html>
ab
</html>
[root@localhost nginx]# ./sbin/nginx
http://192.168.88.170/

[root@localhost nginx]# vi conf/nginx.conf
location / {
            root   html;
            index   index.html index.htm;
        }

[root@localhost nginx]# ps aux|grep nginx
root      8912  0.0  0.0  20292   608 ?        Ss   03:19   0:00 nginx: master process ./sbin/nginx
nobody    8913  0.0  0.1  20688  1396 ?        S    03:19   0:00 nginx: worker process
root      8942  0.0  0.0 103248   864 pts/0    S+   03:22   0:00 grep nginx
[root@localhost nginx]# kill -HUP 8912
http://192.168.88.170/

[root@localhost nginx]# vi html/ab.html

<html>
<script>window.location.href='/'</script>
ab
</html>
[root@localhost nginx]#  kill -HUP 8912
[root@localhost nginx]# ls logs/
access.log  error.log  nginx.pid
不能直接mv 文件名因为他们的inodey相同
Kill -USR1 `cat /xxx/path/log/nginx.pid`重做日志
[root@localhost nginx]# sbin/nginx -h
nginx version: nginx/1.4.2
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/nginx/)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file
[root@localhost nginx]# sbin/nginx -s reload
[root@localhost nginx]# sbin/nginx -s stop
[root@localhost nginx]# sbin/nginx  -s reopen   #USR1
[root@localhost nginx]# sbin/nginx  -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok测试配置文件是否配置成功
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

你可能感兴趣的:(nginx安装以及信号量)