nginx-1.2.7 + tcp_proxy_module手动编译安装

Nginx开源软件默认没有提供TCP协议的负载均衡,下面记录一下我的安装过程: 

1. 下载nginx最新稳定版的源码。可访问:
http://www.nginx.org 或 
linux命令下载到本地:
 

Bash代码  收藏代码
  1. wget http://www.nginx.org/download/nginx-1.2.7.tar.gz  



2. 解压至当前目录:

Bash代码  收藏代码
  1. tar  -zxvf nginx-1.2.7.tar.gz  

当前目录下将新增目录nginx-1.2.7. 

3. 此外,nginx_tcp_proxy_module会用到openssl(http://www.openssl.org)的支持,安装中需要这个包,也需要zlib(http://www.zlib.net)包,所以同样的也都下载并解压放到nginx-1.2.7目录内。 

4. 安装nginx 默认需要pcre(http://www.pcre.org)包的支持,下载到并解压放入nginx-1.2.7 目录内。 

5. 下载 nginx_tcp_proxy_module https://github.com/yaoweibin/nginx_tcp_proxy_module 

6. 下载完成后解压生成目录nginx_tcp_proxy_module-master 并放到 nginx-1.2.7 目录内。 

7. 进入nginx目录,命令:

Bash代码  收藏代码
  1. cd nginx-1.2.7  



8. 以补丁方式加入到nginx:
 

Bash代码  收藏代码
  1. patch -p1 < nginx_tcp_proxy_module-master/tcp.patch  



9. 配置安装,运行:

Bash代码  收藏代码
  1. ./configure --add-module=nginx_tcp_proxy_module-master  --with-pcre=pcre-8.32 --with-openssl=openssl-1.0.1e --with-zlib=zlib-1.2.7 --with-poll_module --prefix=/home/lyh/softs/nginx-1.2.7/run  


--prefix 建议是取绝对路径,好处是可以在任务位置定位到nginx命令启动,不会出现找不到配置文件的错误。 

10. 编译,运行命令 

Bash代码  收藏代码
  1. make  

  编译可能需要5分钟左右,依机器配置时间会不同。 

11. 编译完成后安装,命令:

Bash代码  收藏代码
  1. make install  



12. nginx-1.2.7/run/ 目录下即是安装后的文件,这种安装方式不会随系统启动自动启动服务,需要手动启动或用命令加入到自启动配置中。 

准备好后(第7步)及以后的安装命令如下:
 

Bash代码  收藏代码
    1. ~$ cd nginx-1.2.7  
    2. ~$ patch -p1 < nginx_tcp_proxy_module-master/tcp.patch  
    3. ~$ ./configure --add-module=nginx_tcp_proxy_module-master  --with-pcre=pcre-8.32 --with-openssl=openssl-1.0.1e --with-zlib=zlib-1.2.7 --with-poll_module --prefix=/home/lyh/softs/nginx-1.2.7/run  
    4. ~$  make  
    5. ~$  make install   
原文地址:https://www.cnblogs.com/cnsanshao/p/3334406.html