nginx编译方法

  1. 1. 下载代码
  2. 2. 安装必要的编译软件
  3. 3. 安装必要的库文件
  4. 4. 配置nginx编译环境
  5. 5. 编译

从nginx源码编译安装nginx

1. 下载代码

hg管理的源码库:
http://hg.nginx.org/nginx/file/tip

github的只读库:
https://github.com/nginx/nginx

2. 安装必要的编译软件

基本编译软件gcc g++ cmake automake

sudo apt-get install gcc g++ cmake automake

3. 安装必要的库文件

  • openssl
sudo apt-get install openssl libssl-dev
  • pcre
sudo apt-get install libpcre3 libpcre3-dev
  • zlib
sudo apt-get install zlib1g-dev

4. 配置nginx编译环境

./auto/configure  \
    --prefix=   \
    --with-debug \
    --sbin-path=nginx \
    --conf-path=conf/nginx.conf \
    --error-log-path=logs/error.log  \
    --http-log-path=logs/access.log  \
    --pid-path=logs/nginx.pid \
    --http-client-body-temp-path=temp/client_body_temp \
    --http-proxy-temp-path=temp/proxy/ \
    --http-fastcgi-temp-path=temp/fcgi/ \
    --http-uwsgi-temp-path=temp/uwsgi \
    --http-scgi-temp-path=temp/scgi \
    --with-http_ssl_module \
    --with-http_stub_status_module \
    --with-http_gzip_static_module \
    --with-pcre \
    --with-stream_ssl_module \
    --with-stream \
    --add-dynamic-module=../njs/nginx  #njs module

也可以修改文件\nginx\auto\options

5. 编译

make

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 wind.kaisa@gmail.com

💰

×

Help us with donation