系统:Centos6.6 64位
Nginx: http://nginx.org/en/download.html 今朝最新版本1.9.4 我下载1.8.0
下载模块依赖性Nginx需要依赖下面3个包
1.gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ )
2.rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/ )
3.ssl 成果需要 openssl 库 ( 下载: http://www.openssl.org/ )
依赖包安装顺序依次为:openssl、zlib、pcre, 然后安装Nginx包
假如没有安装c++编译情况,还得安装,通过yum install gcc-c++完成安装
下载完成后:
下一步,编译安装
openssl :
[[email protected]] tar zxvf openssl-fips-2.0.9.tar.gz
[[email protected]] cd openssl-fips-2.0.9
[[email protected]] ./config && make && make install
pcre:
[[email protected]] tar zxvf pcre-8.36.tar.gz
[[email protected]] cd pcre-8.36
[[email protected]] ./configure && make && make install
zlib:
[[email protected]]tar zxvf zlib-1.2.8.tar.gz
[[email protected]] cd zlib-1.2.8
[[email protected]] ./configure && make && make install
最后安装nginx
[[email protected]]tar zxvf nginx-1.8.0.tar.gz
[[email protected]] cd nginx-1.8.0
[[email protected]] ./configure && make && make install
启动呼吁:/usr/local/nginx/sbin/nginx
发明报错了:
error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
经网上查询,这是linux的通病
[[email protected] nginx]# sbin/nginx
sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[[email protected] nginx]# error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[[email protected] nginx]# whereis libpcre.so.1
libpcre.so: /lib64/libpcre.so.0 /usr/local/lib/libpcre.so /usr/local/lib/libpcre.so.1
[[email protected] nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[[email protected] nginx]# sbin/nginx
先找到libpcre.so.1地址位置,然后做个软链接就可以了。
查察是否已启动:
通过欣赏器会见:
看到这个就说明nginx安装并启动乐成。
ps:
启动:/usr/local/nginx/sbin/nginx
遏制/从头加载:/usr/local/nginx/sbin/nginx -s stop(quit、reload)
验证设置文件是否正当:/usr/local/nginx/sbin/nginx -t
呼吁辅佐:/usr/local/nginx/sbin/nginx -h