2. tar -zxvf nginx-1.8.1.tar.gz
3. mv nginx-1.8.1 /usr/local
4. cd /usr/local
5. ln -s nginx-1.8.1 nginx
6. cd nginx
7. ./configure,出现./configure: error: the HTTP rewrite module requires the PCRE library...
8. 下载PCRE:wget http://downloads.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.zip?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fpcre%2Ffiles%2Fpcre2%2F10.21%2F&ts=1457715675&use_mirror=jaist
9. unzip pcre-8.38.zip
10.mv pcre-8.38 /usr/local
11.cd /usr/local;
12.ln -s pcre-8.38 pcre
12.cd pcre
13../configure;make;make install
14.cd /usr/local/nginx; ./configure,发现:Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1: using system crypto library
+ using system zlib library
15.下载openssl:wget http://www.openssl.org/source/openssl-1.0.2g.tar.gz
16.tar -zxvf openssl-1.0.2g.tar.gz; mv openssl-1.0.2g /usr/local; cd /usr/local;ln -s openssl-1.0.2g openssl;cd openssl; ./config ;make;make install;
17.cd /usr/local/nginx; ./configure;仍然发现OpenSSL library is not used;然后执行 ./configure --with-openssl=/usr/local/openssl
18. /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf,提示找不到libpcre.so.1
19. ldd $(which /usr/local/nginx/sbin/nginx),发现/usr/local/lib下有libpcre.so.1 。 另外,/lib64下也有类似文件libpcre.so.0.0.1
20.cd /lib64; ln -s libpcre.so.0.0.1 libpcre.so.1
20.再执行,/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf,然后通过浏览器访问:http://ip访问,打开nginx欢迎页面,OK。
注意:有时安装到最后一步make install时,会发现cp: 'conf/koi-win' and '/usr/local/nginx/conf/koi-win' are the same file,主要原因就是/usr/local/nginx既是tar.gz解压后的目录,又是安装的目的目录,而如果目录重合的话,conf文件夹中的文件在从源目录拷贝到目的目录时会发现源和目的相同,所以提示错误。所以安装时最好是不要ln -s nginx-1.8.3 nginx,而是在nginx-1.8.3目录下执行configure,并指定prefix:./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-openssl=/usr/local/openssl --with-http_ssl_module ,如果没有"--with-http_ssl_module",则可能会报错:“unknown directive "ssl" in /usr/local/nginx/conf/nginx.conf:41”
参考文章:http://www.cnblogs.com/skynet/p/4146083.html