nginx运维(持续更新ing……)

来源:互联网 发布:粤语听古仔软件下载 编辑:程序博客网 时间:2024/06/01 16:57

1.重启

[root@iZ25phahu3aZ nginx]# cd sbin/
[root@iZ25phahu3aZ sbin]# ls
nginx
[root@iZ25phahu3aZ sbin]# pwd
/usr/local/nginx/sbin
[root@iZ25phahu3aZ sbin]# ls
nginx
[root@iZ25phahu3aZ sbin]# ps -ef | grep nginx
root     20195     1  0 Dec16 ?        00:00:00 nginx: master process ./nginx
nobody   20196 20195  0 Dec16 ?        00:00:00 nginx: worker process
root     21697 21660  0 19:39 pts/0    00:00:00 grep nginx
[root@iZ25phahu3aZ sbin]# kill -QUIT 20195 20196
[root@iZ25phahu3aZ sbin]# ps -ef | grep nginx
root     21701 21660  0 19:40 pts/0    00:00:00 grep nginx
[root@iZ25phahu3aZ sbin]# ./nginx
[root@iZ25phahu3aZ sbin]# ps -ef | grep nginx
root     21703     1  0 19:41 ?        00:00:00 nginx: master process ./nginx
nobody   21704 21703  0 19:41 ?        00:00:00 nginx: worker process
root     21706 21660  0 19:41 pts/0    00:00:00 grep nginx
[root@iZ25phahu3aZ sbin]#

2.查看配置文件改得对否,参考上面。
            ./nginx -t

3.Nginx动静分离
             配置nginx.conf文件如下:
              location = / {
                  proxy_pass http://localhost:8080;
              }
              location ~* \.(gif|jpg|jpeg|png|css|js|ico|html)$ {
                  root  /home/myapp/navi;
              }
              location / {
                  proxy_pass http://localhost:80;
              }
             第一个location意思是,严格匹配,如果是根uri就直接pass到resin,不管后面三个location。
             第二个location意思是,正则表达式匹配,如果匹配成功就在/home/myapp/navi下打对应的文件。匹配不成功跳到下个location。
             第三个location意思是,上面的都不符合时走这个。
             一二静态,三动态,可以匹配.jsp,.ajax等uri
0 0