nginx-1.10.3部署正向代理

#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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章