nginx安装-源码编译

官方文档:http://nginx.org/en/docs/configure.html

参考:http://jingyan.baidu.com/article/e2284b2b45f693e2e6118de5.html

升级参考:http://urchin.blog.51cto.com/4356076/988860/  

         http://www.cnblogs.com/terrysun/archive/2012/11/22/2782472.html

编译源码需要的组件

1.zlib  http://www.zlib.net/

2.pcre http://www.pcre.org/            正则表达式

3.openssl  http://www.openssl.org/  可选

4.nginx     http://nginx.org/en/download.html

 ---------------------------------------------------------------- 

1.编译zlib (version 1.1.3 — 1.2.8)

mkdir /usr/src/zlib 
cd /usr/src/zlib
wget  http://zlib.net/zlib-1.2.8.tar.gz
tar xvf zlib-1.2.8.tar.gz

cd /usr/src/zlib/zlib-1.2.8
./configure --static --prefix=/usr/src/zlib/zlib-1.2.8 make make install

2.编译openssl 

 直接使用apt-get进行安装 
sudo apt-get install openssl
sudo apt-get install libssl-dev

3.编译pcre (version 4.4 — 8.38)

mkdir /usr/src/pcre
wget  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
tar xvf pcre2-8.38.tar.gz
/configure --prefix=/usr/src/pcre/pcre-8.38

make install

4.编译ngnix

复制代码
mkdir /usr/src/nginx
cd /usr/src/nginx
wget http://nginx.org/download/nginx-1.9.14.tar.gz
tar xvf nginx-1.9.14.tar.gz
mv nginx-1.9.14 nginx
./configure --prefix=/usr/local/nginx/  --conf-path=/usr/local/nginx/nginx.conf --sbin-path=/usr/local/nginx/sbin/nginx --with-debug --with-openssl=/usr/src/openssl/openssl-1.0.2g --with-zlib=/usr/src/zlib/zlib-1.2.8 --with-pcre=/usr/src/pcre/pcre-8.38 --with-http_stub_status_module --with-http_gzip_static_module 
  
make install
复制代码

生成的nginx在/usr/local/nginx/sbin下

./nginx -v 检测是否安装成功
./nginx 启动
在地址栏输入: http://localhost 如果看到以下效果,说明正确安装了

原文地址:https://www.cnblogs.com/zjxbetter/p/5387485.html