linux下nginx安装步骤,按路径分发配置记录

先安装前置开发类库,默认是已经安装好的。我的系统是centos7

安装g++

cd /usr/local/src

yum install gcc gcc-c++

安装zlib库

cd /usr/local/src
 
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install

安装openssl

cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz

安装pcre,pcre作用是让 Nginx 支持 Rewrite 功能。

cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz 
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.34
./configure
make
make install

安装nginx

cd /usr/local/src
wget http://nginx.org/download/nginx-1.1.10.tar.gz
tar -zxvf nginx-1.1.10.tar.gz
cd nginx-1.1.10
./configure
make
make install

这里没问题就安装成功了。

修改配置文件,按请求路径分发到不同的tomcat,配置文件在安装完成的目录下 /usr/local/nginx/conf/nginx.conf

#upstream表示负载服务器池
	upstream tcis { 
	    server 192.168.1.9:8080;
	    server 192.168.1.9:8081;
	}

	upstream wxDev { 
	    server 192.168.1.9:8082;
	    server 192.168.1.9:8083;
	}


server {
        listen       80;
        server_name  192.168.1.9;

        #charset utf-8;

        #access_log  logs/host.access.log  main;

        location /tcis {
			proxy_pass http://tcis;
        }

        location /wxDev {
			proxy_pass http://wxDev; 
        }
}

这样配置之后,192.168.1.9:80/tcis的请求会以轮询的方式分发到8080和8081两个tomcat上。

 

nginx的启动,关闭,启动命令

启动:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

停止
./nginx -s stop

重新加载配置文件
./nginx -s reload

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值