概述: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