LNMP编译:nginx的安装

编译nginx前依赖包安装:

# install pcre for nginx
if [ -s pcre-8.34.tar.gz ]; then
echo “pcre-8.34.tar.gz [found]”
else
echo “Error: pcre-8.34.tar.gz not found!!!download now……”
wget -c http://mirrors.boxcore.org/lnmp/pcre-8.34.tar.gz
fi
tar zxvf pcre-8.34.tar.gz
cd pcre-8.34/
./configure
make && make install
cd ../
ldconfig

 

开始编译nginx:

下载解压:

tar zxvf nginx-1.4.4.tar.gz
cd nginx-1.4.4/

 

configure配置项:

如果你的nginx依赖件已经用yum先安装好,可以使用下面命令:

./configure –user=$LNMP_USER –group=$LNMP_USER –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_gzip_static_module –with-ipv6 –with-pcre

如果nginx依赖包是编译的,需要指定目录:

./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_gzip_static_module –with-ipv6 –with-openssl=/usr/include/openssl –with-pcre

 

如果报错

error:openssl/include/openssl/ssl.h] Error 2

需要确定openssl是否安装好,如果是yum安装openssl-devel后,configure时的参数去掉–with-openssl=/lib64/ –with-zlib=/usr/lib64/ –with-md5=/usr/lib64即可编译通过