nginx源码编译安装

nginx源码安装总结

依赖下载安装

zlib

下载地址:https://zlib.net/fossils/
下载版本:zlib-1.2.12.tar.gz

tar zxvf zlib-1.2.12.tar.gz
cd zlib-1.2.12.tar.gz
./configure --prefix=/usr/local/zlib

pcre

下载地址:https://sourceforge.net/projects/pcre/files/pcre/
下载版本:pcre-8.35.tar.gz

tar zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure --prefix=/usr/local/pcre

openssl

下载地址:https://www.openssl.org/source/old/
下载版本:openssl-1.0.1i.tar.gz

tar -zxvf openssl-1.0.1i.tar.gz
cd openssl-1.0.1i
./config --prefix=/usr/local/openssl

nginx编译安装

下载地址:http://nginx.org/en/download.html
下载版本:nginx-1.22.1.tar.gz

tar zxvf  nginx-1.22.1.tar.gz
cd nginx-1.22.1
./configure --prefix=/usr/local/nginx --with-zlib=zlib-path --with-openssl=openssl-path --with-pcre=pcre-path --with-http_ssl_module --with-stream

--with-zlib=zlib-path:是指zlib的源码路径而不是安装路径(其他的依赖也是一样)
--with-stream:是为了支持stream模块,跟http模块类似,stream模块是为了实现tcp/udp端口转发的,与协议无关;http模块则是为了实现http请求转发的

nginx配置

在/usr/local/nginx/conf/nginx.conf中添加以下配置

http{
	server{
		listen 8081;//监听http请求8081
		name 8081.com;//可不写
		location /test{
			proxy_pass http://10.1.1.1:8081;//必须按http://ip:port的形式
		}
	}
}

添加stream:
stream{
	server{
		listen 1554;
		proxy_pass 10.1.1.1:1554;
	}
}


测试

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值