# wget https://nginx.org/download/nginx-1.9.9.tar.gz # tar -zxvf nginx-1.9.9.tar.gz # cd nginx-1.9.9 # ./configure --prefix=/usr/nginx/nginx-1.9.9
执行 make、make install
测试:
# ./sbin/nginx -t
输出:
nginx: the configuration file /usr/nginx/nginx-1.9.9/nginx.conf syntax is ok nginx: configuration file /usr/nginx/nginx-1.9.9/nginx.conf test is successful
启动:
# ./sbin/nginx -c /usr/nginx/nginx-1.9.9/nginx.conf
报错一:
checking for OS
+ Linux 3.10.0-514.16.1.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
执行:
# yum install gcc gcc-c++ kernel-devel
报错二:
cp: `conf/koi-win' and `/usr/local/nginx/conf/koi-win' are the same file
执行:
# ./configure --prefix=/usr/nginx/nginx-1.9.9 --conf-path=/usr/nginx/nginx-1.9.9/nginx.conf
至此,nginx安装完毕,配置正向HTTP代理:
编辑 nginx.conf 文件:
server { resolver 8.8.8.8; resolver_timeout 5s; listen 0.0.0.0:8088; location / { proxy_pass $scheme://$host$request_uri; proxy_set_header Host $http_host; proxy_buffers 256 4k; proxy_max_temp_file_size 0; proxy_connect_timeout 30; proxy_cache_valid 200 302 10m; proxy_cache_valid 301 1h; proxy_cache_valid any 1m; }
重启nginx:
# ./sbin/nginx -s reload
测试:
浏览器配置HTTP代理,配置完成: