概述:Nginx是一個輕便的支持高併發的HTTP和反向代理服務器,運用很廣。這裏記錄下Linux下Nginx的安裝步驟,這裏以centos系統爲例,安裝Nginx1.7.9,安裝目錄爲/usr/local。
一、安裝Nginx依賴環境
1、安裝gcc-c++
# yum install -y gcc-c++
2、下載pcre
#cd /usr/local
#wget http://sourceforge.net/projects/pcre/files/pcre/8.35/pcre-8.35.tar.gz
#tar zxvf pcre-8.35.tar.gz
3、安裝zlib
# cd /usr/local
# wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz
# tar zxvf zlib-1.2.8.tar.gz
# cd zlib-1.2.8
# ./configure --prefix=/usr/local/zlib
# make && make install
4、安裝openl
# cd /usr/local
# wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz
# tar zxfv openssl-1.0.1h.tar.gz
# cd openssl-1.0.1h
# ./config --prefix=/usr/local/openssl
# make && make install
二、安裝Nginx
# cd /usr/local
# wget http://nginx.org/download/nginx-1.7.9.tar.gz
# tar zxvf nginx-1.7.9.tar.gz
# cd nginx-1.7.9
#./configure --with-pcre=/usr/local/pcre-8.35 --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-zlib=/usr/local/zlib-1.2.8 --with-openssl=/usr/local/openssl-1.0.1h
#make && make install
解決nginx啓動時報錯:
[error]open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file ordirectory)
#/usr/local/nginx/sbin/nginx -c/usr/local/nginx/conf/nginx.conf
參考文章:http://blog.csdn.net/fengyily/article/details/35569671