#yum 安装环境
yum -y install gcc-c++
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
#下载以下软件包
pcre-8.42.tar.gz master.zip nginx-upstream-fair-master.zip ngx_http_proxy_connect_module-master.zip
#解压相关依赖包
将下载的pcre-8.42.tar.gz master.zip nginx-upstream-fair-master.zip ngx_http_proxy_connect_module-master.zip 解压在/usr/local/路径下
#编译安装pcre
cd /usr/local/pcre-8.42
./configure
make
make install
#创建nginx启动用户
useradd -s /sbin/nologin -M nginx
nginx-1.10.3.tar.gz 解压在 /usr/local/src/路径下
#编译安装nginx
cd nginx-1.10.3
yum groupinstall -y "Development Tools"
yum install -y patch pcre-devel pcre zlib-devel zlib
patch -p1 </usr/local/ngx_http_proxy_connect_module-master/patch/proxy_connect.patch
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/usr/local/nginx-upstream-fair-master/ --add-module=/usr/local/ngx_cache_purge-master --add-module=/usr/local/ngx_http_proxy_connect_module-master --with-pcre=/usr/local/pcre-8.42/ --with-stream
make
make install
#添加nginx启动服务
cd /etc/init.d/
rz 上传nginx启动脚本(nginx)
chmod 777 nginx
chkconfig --add nginx
chkconfig --list nginx
chkconfig nginx on
#上传nginx配置
cd /usr/local/nginx/conf/
rz nginx.conf
nginx.conf 配置默认即可
#配置检查
检查nginx配置是否正确
/usr/local/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
service nginx restart