zoukankan      html  css  js  c++  java
  • nginx编译记

    /**

     * @author       Sun Yongyue

     * @comment   有点久了,入门级的东东,今天翻到就放出来吧

     */

    nginx编译记

    -- with pcre/zlib/openssl preinstall


    不想让nginx和pcre、openssl、zlib等一起安装(事实上一起做静态编译的话,nginx的性能会好一点,不过这个地方只是个人环境,不用考虑)。

    开始尝试编译时,使用一些资料上的with-pcre、with-zlib、with-openssl参数。后来一直不成功,修改N次后无果,google之。查看很多资料之后,锁定以下几篇。


    [1] 发现objs/autoconf.err里边提示md5.h找不到,google到nginx的作者回答的一个类似问题:
    > > The --with-openssl= option should point to OpenSSL sources, but not
    > > to inlcudes and binary libraries.
    > OK thx for the answer.
    As your OpenSSL is set in non-standard place (I have just tested building
    on Debian with standard /usr/include/openssl/md5.h), you should use
    something like this:
     --with-cc-opt=-I/usr/local/openssl-0.9.6/include
    原来with-openssl等参数是指向源代码,而非安装路径。

    [2] 头文件加上后,再加上lib文件的路径
    You may try
    ./configure --with-cc-opt="-I /path/to/includes"
    --with-ld-opt="-L /path/to/libraries"

    [3] 发现还是不行,原来是我没有去掉with-openssl、with-pcre、with-zlib等参数,去掉后,把相应的include和lib加入到cc-opt和lb-opt,编译OK。

    [4] 运行时发现so文件找不到,google到这个。应该是指定运行时的so文件连接。
    Posted by Igor Sysoev (Guest) 
    on 2010-08-03 22:08
    On Tue, Aug 03, 2010 at 03:38:27PM -0400, WilliamOMS wrote:
    > ld.so.1: nginx: fatal: libpcre.so.0: open failed: No such file or
    > directory
    > Killed
    Then
    ./configure --with-cc-opt="-I/path/to/includes"
    --with-ld-opt="-R/path/to/lib -L/path/to/lib"


    [5] 运行时还是找不到,才想起来make的时候最后有提示gcc: unrecognized option "-R",继续google之,找到一个rpath替换掉R,还是unrecognized,继续google,得到一个Wl参数。编译done。
    checking for --with-ld-opt="-rpath /home/djeyewater/apps/GeoIP/lib
    > -L /home/djeyewater/apps/GeoIP/lib"
    > gcc: unrecognized option '-rpath'
    > /home/djeyewater/apps/GeoIP/lib: file not recognized: Is a directory
    > collect2: ld returned 1 exit status
     Oh, sorry, I have just noticed that this is an gcc's error, but not
    linker's one. Try
     --with-ld-opt="-Wl,-R,$HOME/apps/GeoIP/lib -L $HOME/apps/GeoIP/lib"
     or
     --with-ld-opt="-Wl,-rpath,$HOME/apps/GeoIP/lib -L $HOME/apps/GeoIP/lib"


    [6] 顺便test一下,nginx -t提示tmp路径有问题,记得是自己设置的,估计是nginx不会自动make上一级目录的源故,mkdir一个路径,OK。又提示bind 80端口时,permission denied,google之,得知1024以内的端口需要用root权限才能去bind。改端口为8020,test OK。
    Re: Cannot listen to port 80 but 3000, 3080 without Apache
    January 04, 2010 09:24PM
     
    Mauro Stettler wrote:
    > you have to start it as root, users don't have privs to open ports below
    > 1024

    编译命令
    ./configure --with-openssl=$HOME/local/openssl --prefix=$HOME/local/nginx --with-cc-opt="-I/home/sun/local/zlib/include -I/home/sun/local/openssl/include -I/home/sun/local/pcre/include" --with-ld-opt="-L/home/sun/local/zlib/lib -Wl,-R,/home/sun/local/openssl/lib -L/home/sun/local/openssl/lib -L/home/sun/local/pcre/lib -Wl,-R,/home/sun/local/pcre/lib -lssl -lcrypto" --http-proxy-temp-path=tmp/proxy_temp/ --http-client-body-temp-path=tmp/client_body_temp/ --http-fastcgi-temp-path=tmp/fastcgi_temp/ --http-uwsgi-temp-path=tmp/uwsgi_temp/ --http-scgi-temp-path=tmp/scgi_temp/  --pid-path=var/nginx.pid
    update:
    2011-06-20
    编译参数 --with-http_stub_status_module,用来看状态。之前只关心开发没用上,现在要更深入一点了解学习。
  • 相关阅读:
    IC79620: USER'S ROUTINE MAY BE TERMINATED ABNORMALLY IF SOME SYSTEMROUTINES WERE RUN IN DB2FMP BEFORE
    SQL1042C running a fenced routine (stored procedure/UDF)
    新创建的数据库,执行db2look时,遇到package db2lkfun.bnd bind failed
    【转载】JSP生成静态Html页面
    【新闻发布系统】项目文档
    【新闻发布系统】登录和注销的实现
    【tomcat】关于tomcat的使用:将tomcat加入系统服务列表
    【JavaWeb】JSP九大内置对象
    【学习笔记】JDBC数据库连接技术(Java Database Connectivity)
    【学习笔记】2017年7月18日MySQL测试:模拟QQ数据库
  • 原文地址:https://www.cnblogs.com/sunyongyue/p/nginx_compile.html
Copyright © 2011-2022 走看看