美文网首页
ubuntu nginx源代码安装

ubuntu nginx源代码安装

作者: qboy0000 | 来源:发表于2019-03-28 22:55 被阅读0次

    下载源代码

    http://nginx.org/en/download.html

    tar -xvf nginx-<version>.tar.gz
    ./configure

    ./configure: error: the HTTP rewrite module requires the PCRE library.
    You can either disable the module by using --without-http_rewrite_module
    option, or install the PCRE library into the system, or build the PCRE library
    statically from the source with nginx by using --with-pcre=<path> option.
    

    安装pcre

    sudo apt install libpcre3 libpcre3-dev

    继续安装nginx

    ./configure: error: the HTTP gzip module requires the zlib library.
    You can either disable the module by using --without-http_gzip_module
    option, or install the zlib library into the system, or build the zlib library
    statically from the source with nginx by using --with-zlib=<path> option.
    

    安装zlib

    下载地址:http://www.zlib.net/

     tar -xvf zlib-<version>.tar.gz 
     cd zlib-<version>/
    ./configure
    make
    make install
    

    继续configure nginx,编译没有问题了

    make && make install

    源码的安装路径为 /usr/local/nginx/sbin/nginx 而采用apt安装的路径为/usr/sbin/nginx
    apt安装的版本为1.10.3 源代码安装的版本是1.15.10
    以下为了实现平移

    1. 结束nginx进程
    2. 将/usr/sbin/nginx备份一下 并创建软链接
    mv /usr/sbin/nginx /usr/sbin/nginx_old
    ln -s /usr/local/nginx/sbin/nginx  /usr/sbin/nginx
    

    再次启动时:

    Failed to start A high performance web server and a reverse proxy server.

    重新编译:

    ./configure --with-http_ssl_module

    ./configure: error: SSL modules require the OpenSSL library.
    You can either do not enable the modules, or install the OpenSSL library
    into the system, or build the OpenSSL library statically from the source
    with nginx by using --with-openssl=<path> option.
    

    安装ssl library

    源码:https://www.openssl.org/source/

      $ ./config
      $ make
      $ make test
      $ make install
    

    nginx:

    ./configure --with-http_ssl_module --with-openssl=<ssl_src path>
    make && make install

    运行:

    nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:78

    nginx重新配置

    ./configure --with-http_ssl_module --with-openssl=<ssl_src path> --with-stream
    make && make install

    相关文章

      网友评论

          本文标题:ubuntu nginx源代码安装

          本文链接:https://www.haomeiwen.com/subject/btjcbqtx.html