接着上一篇日志,CentOS5.5 Nginx环境搭建有几个程序库要先安装:
1、GCC,GCC-C++
2、Zlib
3、pcre
4、openssl
详细安装步骤如下:
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak
wget http://mirrors.163.com/.help/CentOS-Base-163.repo
mv CentOS-Base-163.repo CentOS-Base.repo
yum makecache
mkdir -p /home/software
cd /home/software
一、GCC
可以直接用yum来安装
yum -y install gcc
yum -y install gcc-c++
二、Zlib安装
下载地址:http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib-1.2.5.tar.gz/download
cd /home/software
wget http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib-1.2.5.tar.gz/download
tar zxvf zlib-1.2.5.tar.gz
cd zlib-1.2.5
./configure
make
make install
三、pcre安装
下载地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
cd /home/software
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
tar zxvf pcre-8.30.tar.gz
cd pcre-8.30
./configure
make
make install
四、openssl安装
下载地址:http://www.openssl.org/source/openssl-1.0.0g.tar.gz
cd /home/software
wget http://www.openssl.org/source/openssl-1.0.0g.tar.gz
tar zxvf openssl-1.0.0g.tar.gz
cd openssl-1.0.0g
./config --prefix=/usr/local/ --openssldir=/usr/local/openssl-1.0.0g shared zlib-dynamic enable-camellia enable-tlsext
make
make install
五、nginx安装
下载地址:http://nginx.org/download/nginx-1.0.13.tar.gz
cd /home/software
wget http://nginx.org/download/nginx-1.0.13.tar.gz
tar zxvf nginx-1.0.13.tar.gz
cd nginx-1.0.13
./configure \
--user=nginx \
--group=nginx \
--prefix=/usr/share \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/log/run/nginx.pid \
--lock-path=/var/log/lock/subsys/nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_perl_module \
--with-mail \
--with-mail_ssl_module
make
make install
为Nginx建立用户
/usr/sbin/useradd -c "Nginx user" -s /bin/false -r -d /var/lib/nginx nginx
运行Nginx
/usr/sbin/nginx
注意:此处运行nginx会出现错误:
error while loading shared libraries:libpcre.so.1:cannot open shared object file: no such file or directory
从错误看出是缺少lib文件导致,进一步查看下
ldd /usr/sbin/nginx
运行ldd /usr/sbin/nginx会发现:
libpcre.so.1=> not found
libssl.so.1.0.0=> not found
libcrypto.so.1.0.0=> not found
这三个文件 not found只需要进入/lib目录中手动链接下
ln -s libcrypto.so.0.9.8.e libcrypto.so.1.0.0
ln -s libssl.so.0.9.8e libssl.so.1.0.0
ln -s libpcre.so.0.0.1 libpcre.so.1
然后在启动nginx ok 了