1.yum安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
2 手动安装
2.1可选择手动下载,编译&安装PCRE库(让 Nginx 支持 Rewrite 功能)
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
tar -zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure
make && make install
2.2 下载编译安装SSL库
> wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
> tar -zxvf openssl-1.0.1j.tar.gz
> cd openssl-1.0.1j
> ./config
make && make install
2.3 下载编译安装zlib依赖库
> wget http://zlib.net/zlib-1.2.11.tar.gz
> tar -zxvf zlib-1.2.11.tar.gz
> cd zlib-1.2.11
> ./config
make && make install
3.安装Nginx
> wget http://nginx.org/download/nginx-1.8.0.tar.gz
> tar -zxvf nginx-1.8.0.tar.gz
> cd nginx-1.8.0
./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with- http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module
make && make install
-prefix=/usr/local/nginx指定编译安装的目录
4.启动 Ngin服务
> cd /usr/local/nginx (不指定配置文件地址)
> /usr/local/nginx/nginx -c/usr/local/nginx/nginx.conf (指定配置文件地址)
> ./sbin/nginx
> ./sbin/nginx -t
5.Nginx服务
> ps -ef|grep nginx
> kill
> ./sbin/nginx -s reload
6.Nginx 参数说明
–prefix
–pid-path
–lock-path
–with-http_ssl_module
–with-http_dav_module
–with-http_flv_module
–with-http_realip_module
–with-http_gzip_static_module
–with-http_stub_status_module
–with-mail
–with-mail_ssl_module
–with-pcre=../pcre-8.11
–with-zlib=../zlib-1.2.5
–with-debug
–http-client-body-temp-path
–http-proxy-temp-path
–http-fastcgi-temp-path
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
–http-scgi-temp-path=/var/tmp/nginx/scgi
6.1 查看服务的安装位置
> whereis nginx
> cd /usr/local/nginx/sbin/
> ./nginx
> ./nginx -s stop
> ./nginx -s quit
> ./nginx -s reload
6.2 开机自启动
> vi /etc/rc.local
> /usr/local/nginx/sbin/nginx
chmod 755 rc.local