Nginx
高性能HTTP,反向代理
========================================================================================================
基本安装
pcre
支持正则表达式,地址重写rewrite
[root@node3 ~]# tar xvf pcre-8.10.tar.gz
[root@node3 pcre-8.10]# ./configure && make && make install
[root@node3 pcre-8.10]# echo $?
0
nginx
[root@node3 ~]# useradd www
[root@node3 nginx-1.2.0]# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module
[root@node3 nginx-1.2.0]# make && make install
[root@node3 ~]# tree /usr/local/nginx/
/usr/local/nginx/
|-- conf
|   |-- fastcgi.conf
|   |-- fastcgi.conf.default
|   |-- fastcgi_params
|   |-- fastcgi_params.default
|   |-- koi-utf
|   |-- koi-win
|   |-- mime.types
|   |-- mime.types.default
|   |-- nginx.conf
|   |-- nginx.conf.default
|   |-- scgi_params
|   |-- scgi_params.default
|   |-- uwsgi_params
|   |-- uwsgi_params.default
|   `-- win-utf
|-- html
|   |-- 50x.html
|   `-- index.html
|-- logs
`-- sbin
    `-- nginx
4 directories, 18 files
========================================================================================================
启动nginx
[root@node3 ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
[root@node3 ~]# ps -ef | grep nginx
root     20721     1  0 14:14 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
www      20722 20721  0 14:14 ?        00:00:00 nginx: worker process                                          
root     20738  5923  0 14:19 pts/1    00:00:00 grep nginx
[root@node3 ~]# netstat -tnlp |grep :80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      13888/nginx 
[root@node3 ~]# echo "/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf" >> /etc/rc.local 
[root@node3 ~]# links --dump http://192.168.122.103
                               Welcome to nginx!
===========================================================================================================
配置Nginx
[root@node3 ~]# vim /usr/local/nginx/conf/nginx.conf
worker_processes  5;初始启动的进程数
worker_connections  1024;最大的连接数
==========================================================================================================
语法检查
[root@node3 ~]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
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
[root@station02 ~]# pgrep nginx
13888
13889
[root@station02 ~]# kill 13888
[root@station02 ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
本文出自 “cisco” 博客,请务必保留此出处http://1585654.blog.51cto.com/1575654/1386515
原文:http://1585654.blog.51cto.com/1575654/1386515