安装包下载地址[3分]: https://download.csdn.net/download/qq_17522211/10885072
1> 检查gcc是否安装
gcc --version
安装: rpm -ivh xxx.rpm
2> 检查g++是否安装
g++ --version
安装: rpm -ivh xxx.rpm
3> 安装zlib
4> 安装libstdc
5> 安装nginx
tar -zxvf nginx-1.21.1.tar.gz
cd nginx-1.21.1
./configure
make
make install
6> nginx操作:
cd /usr/local/nginx/sbin
./nginx -t -c /usr/local/nginx/conf/nginx.conf // 验证nginx配置是否正确
./nginx -c /usr/local/nginx/conf/nginx.conf // 启动nginx
ps -ef|grep nginx // 查看nginx进程
kill nginxid // 停止nginx
./nginx -s reload -c /usr/local/nginx/conf/nginx.conf // 重启nginx
7> 错误
sbin/nginx: error while loading shared libraries: libjemalloc.so.2:
进入/lib目录执行: ln -s libpcre.so.0.0.1 libpcre.so.1
8> 其它一些配置
依据路径进行转发
upstream web1 {
server 127.0.0.1:8081;
}
upstream web2 {
server 127.0.0.1:8082;
}
server {
listen 80;
server_name localhost;
location ^~ /contest26/plat/ {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://web1; // 如果web1后面加/, 如访问contest26/test会转到/test. 如果不加则为contest26/test
}
location ^~ /contest26/pay/ {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://web2;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}