一、准备工作
# yum -y install gcc gcc-c++ make openssl-devel
二、部署Nginx
1. pcre: 支持正则表达式,地址重写rewrite
# yum -y install pcre-devel
2. nginx
[root@localhost ~]# useradd www -s /sbin/nologin
[root@localhost ~]# tar xf nginx-1.8.0.tar.gz
[root@localhost ~]# cd nginx-1.8.0
[root@localhost nginx-1.8.0]# ./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx-1.8.0 \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_ssl_module \
--with-pcre
[root@localhost ~]# make
[root@localhost ~]# make install
[root@localhost ~]# ln -s /usr/local/nginx-1.8.0 /usr/local/nginx
[root@localhost ~]# 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
3. 启动
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# netstat -tnlp |grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10627/nginx
4. 测试
[root@localhost ~]# curl http://192.168.122.186
[root@localhost ~]#/usr/local/nginx/sbin/nginx -s stop
[root@localhost ~]# netstat -tnlp |grep :80
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload
[root@localhost ~]# echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local //开机运行
[root@localhost ~]# curl -I http://192.168.122.52
HTTP/1.1 200 OK
Server: nginx/1.8.0
Date: Tue, 01 Dec 2015 18:49:59 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 01 Dec 2015 18:46:18 GMT
Connection: keep-alive
ETag: "565deafa-264"
Accept-Ranges: bytes




