1. 准备工作

1. 下载 Nginx http://nginx.org/en/download.html

2. 可通过 apt-get 安装 Nginx 需要的库

  • Zlib: sudo sudo apt-get install zlib1g-dev
  • OpenSSL: sudo apt-get install libssl-dev
  • PCRE: sudo apt-get install libpcre3-dev

如果需要手动安装可自行下载新版本的库

  • Zlib: http://www.zlib.net
  • PCRE: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

 

2. 添加用户和组

sudo useradd www-data

sudo groupadd www-data

 

3. 编译

首先安装 gcc 编译器: sudo apt-get install gcc

安装make: sudo apt-get install make

./configure –user=www-data –group=www-data –with-http_ssl_module

或添加其他模块: –add-module=../ngx-fancyindex

之后会看到:

nginx path prefix: “/usr/local/nginx”
nginx binary file: “/usr/local/nginx/sbin/nginx”
nginx configuration prefix: “/usr/local/nginx/conf”
nginx configuration file: “/usr/local/nginx/conf/nginx.conf”
nginx pid file: “/usr/local/nginx/logs/nginx.pid”
nginx error log file: “/usr/local/nginx/logs/error.log”
nginx http access log file: “/usr/local/nginx/logs/access.log”
nginx http client request body temporary files: “client_body_temp”
nginx http proxy temporary files: “proxy_temp”
nginx http fastcgi temporary files: “fastcgi_temp”
nginx http uwsgi temporary files: “uwsgi_temp”
nginx http scgi temporary files: “scgi_temp”

make && make isntall

编译完成

Nginx 配置文件: /usr/local/nginx/conf