Debian 编译安装 nginx 服务器

  1. 下载源码包、解压并进入:
    # 下载; wget http://nginx.org/download/nginx-1.18.0.tar.gz# 解压; tar -zxvf nginx-1.18.0.tar.gz# 进入; cd nginx-1.18.0/

  2. 配置并检测依赖:
./configure --prefix=/home/mu/nginx --user=mu --group=mu --with-http_ssl_module --with-threads --with-http_realip_module --with-http_stub_status_module

编译参数可参考 Building nginx from Sources
  1. 编译安装:
    make && make install

安装时可能出现如下错误:
【Debian 编译安装 nginx 服务器】错误一:
./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= option.

解决方式:
sudo apt-get install libpcre3 libpcre3-dev

错误二:
./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= option.

解决方式:
sudo apt-get install openssl libssl-dev

启动:
cd /home/mu/nginx/sbin/ ./nginx

安装后的其他配置参考:
nginx开启目录浏览,解决中文乱码问题

    推荐阅读