ubuntu 源码安装 nginx

1.安装所需库

sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev 

2.下载源码并解压缩
http://nginx.org/download/
3.编译安装

./configure --prefix=/usr/local/nginx-1.8.0 \
--with-http_ssl_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--with-http_spdy_module \
--with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' \
--with-debug

编译结果…设定的目录为:

  nginx path prefix: "/usr/local/nginx-1.8.0"
  nginx binary file: "/usr/local/nginx-1.8.0/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx-1.8.0/conf"
  nginx configuration file: "/usr/local/nginx-1.8.0/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx-1.8.0/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx-1.8.0/logs/error.log"
  nginx http access log file: "/usr/local/nginx-1.8.0/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"


sudo make && sudo make install