Linux安装Nginx步骤之后续,带stream模块

0.安装nginx

linux安装nginx

1.检查nginx是否安装成功

cd /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

则启动成功

--------------------------------------------------------------------------------------
报错:centos No rule to make target `build', needed by `default
安装前置库:
[root@cqakserver local]# yum install -y gcc pcre pcre-devel openssl openssl-devel gd gd-devel
重新configure make
--------------------------------------------------------------------------------------

2.配置软链接

sudo ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx

就可以不用路径直接输入nginx启动。

3.安装stream模块  

remote tcp负载需要用,如果已经安装过stream则不用安装
(1)bash ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --conf-path=/usr/local/nginx/conf/nginx.conf 
make
(注意:此处只make,不要make install,否则线上配置会被清除,编译参数需要和之前的一样)
(2)mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
(3)cp -rfp ./objs/nginx /usr/local/nginx/sbin
(4)nginx -t   检查是否有报错
(5)在nginx.conf中添加:
# tcp层转发的配置文件夹
include /usr/local/nginx/tcp.d/*.conf;
(6)在tcp.d新建remote.conf

stream{
    upstream remote {
        server 192.168.1.70:8091;
        server 192.168.1.70:8092;
    }
    server {
          listen    18092;
          proxy_pass   remote;
    }
}

(7)重新加载  nginx -s reload

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值