linux-离线方式安装nginx并简单配置

安装包下载地址[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;
        }
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小安灬

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值