zoukankan      html  css  js  c++  java
  • Nginx TCP Proxy模块的编译安装

    这次用一个国内开发者在GitHub上的开源项目https://github.com/yaoweibin/nginx_tcp_proxy_module

    我的系统已经安装了最新的Nginx,现在需要下载源代码编译出自己的版本。

    wget http://nginx.org/download/nginx-1.5.3.tar.gz
    tar zxvf nginx-1.5.3.tar.gz

    然后获得nginx_tcp_proxy_module的项目:

    git clone https://github.com/yaoweibin/nginx_tcp_proxy_module.git


    现在给Nginx打补丁

    cd nginx-1.5.3/
    root@dean-GA-MA790XT-UD4P:/usr/src/nginx-1.5.3# patch -p1 < /usr/src/nginx_tcp_proxy_module/tcp.patch 
    patching file src/core/ngx_log.c
    Hunk #1 succeeded at 69 (offset 3 lines).
    patching file src/core/ngx_log.h
    Hunk #1 succeeded at 30 (offset 1 line).
    Hunk #2 succeeded at 38 (offset 1 line).
    patching file src/event/ngx_event_connect.h
    Hunk #1 succeeded at 33 (offset 1 line).
    Hunk #2 succeeded at 44 (offset 1 line).


    还要安装个ssl库

    apt-get install libssl-dev


    但是卸载掉自动安装的libstdc++6-4.7-dev, 因为我用的是gcc4.8.1

    apt-get autoremove

    好了,现在配置makefile,首先查看当前系统安装好的Nginx的配置选项:

    nginx -V
    nginx version: nginx/1.5.3
    built by gcc 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1) 
    TLS SNI support enabled
    configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --with-ipv6

    然后原封不动的使用这些配置参数,但是加上最后一个

    --add-module=/usr/src/nginx_tcp_proxy_module
    ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --with-ipv6 --add-module=/usr/src/nginx_tcp_proxy_module


    现在开始编译吧。

    make

    得到的nginx程序位于objs目录. 将nginx服务停掉,并替换之。

    service nginx stop
    mv /usr/sbin/nginx /usr/sbin/nginx_bk
    /usr/src/nginx-1.5.3/objs# cp nginx /usr/sbin/
    service nginx start
    ps -def | grep nginx
    root     23479     1  0 23:21 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
    root     23480 23479  0 23:21 ?        00:00:00 nginx: worker process                   
    root     23482 13006  0 23:21 pts/0    00:00:00 grep --color=auto nginx
  • 相关阅读:
    【leetcode】1365. How Many Numbers Are Smaller Than the Current Number
    【leetcode】1363. Largest Multiple of Three
    【leetcode】1362. Closest Divisors
    【leetcode】1361. Validate Binary Tree Nodes
    【leetcode】1360. Number of Days Between Two Dates
    【leetcode】1359. Count All Valid Pickup and Delivery Options
    【leetcode】1357. Apply Discount Every n Orders
    【leetcode】1356. Sort Integers by The Number of 1 Bits
    ISE应用入门的一些问题
    DDR的型号问题
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3283528.html
Copyright © 2011-2022 走看看