ubuntu20.04源码安装nginx

下载

  1. wget http://nginx.org/download/nginx-1.19.0.tar.gz

安装依赖软件

更新源

  1. sudo apt-get update

安装c++依赖库

  1. sudo apt-get install build-essential
  2. sudo apt-get install libtool

安装openssl依赖库

  1. sudo apt-get install openssl

安装pcre依赖库

  1. sudo apt-get install libpcre3 libpcre3-dev

安装zlib依赖库

  1. sudo apt-get install zlib1g-dev

编译

  1. ./configure --prefix=/usr/local/nginx \
  2. --with-http_ssl_module \
  3. --http-client-body-temp-path=/usr/local/nginx/temp/client_body_temp \
  4. --http-proxy-temp-path=/usr/local/nginx/temp/proxy_temp \
  5. --http-fastcgi-temp-path=/usr/local/nginx/temp/fastcgi_temp \
  6. --http-uwsgi-temp-path=/usr/local/nginx/temp/uwsgi_temp \
  7. --http-scgi-temp-path=/usr/local/nginx/temp/scgi_temp

安装

  1. make && make install

启动

  1. cd /usr/local/nginx/sbin
  2. ./nginx