安装Nginx 及使用
1.下载 Nginx
wget http://nginx.org/download/nginx-1.10.3.tar.gz (稳定版)
2.提前下载好依赖包
openssl、zlib、pcre
pcre-devel,gcc-c++
编译安装 openssl、zlib、pcre, 截止 2017.3.22 各官方最新下载链接
wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz
wget http://www.zlib.net/zlib-1.2.11.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.21.tar.bz2
然后一顿解压安装
tar zxvf openssl-1.1.0e.tar.gz
cd openssl-1.1.0e
./config && make && make install
tar -xjf pcre2-10.21.tar.bz2
cd pcre2-10.21
./configure && make && make install
tar zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure && make && make install
最后编译安装 nginx
cd nginx-1.10.3
./configure --prefix=/usr/local/nginx
make && make install
3.碰到一些缺少包的情况,
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libcrypto.so.1.1: canno
解决办法:
find / -name *libcrypto*
做 软链 ln -s /usr/local/lib64/libcrypto.so.1.1 libcrypto.so.1.1
二
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[root@localhost conf]# ldd $(which /usr/local/nginx/sbin/nginx)
linux-gate.so.1 => (0x0071b000)
libpthread.so.0 => /lib/libpthread.so.0 (0×00498000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0×00986000)
libpcre.so.1 => not found
libcrypto.so.6 => /lib/libcrypto.so.6 (0×00196000)
libz.so.1 => /lib/libz.so.1 (0×00610000)
libc.so.6 => /lib/libc.so.6 (0x002d7000)
/lib/ld-linux.so.2 (0x006a8000)
libdl.so.2 => /lib/libdl.so.2 (0x008c3000)
可以看出 libpcre.so.1 => not found 并没有找到,进入/lib目录中手动链接下
[root@localhost lib]# ln -s libpcre.so.0.0.1 libpcre.so.1
最后启动后,验证nginx 是否运行有效,
netstat -antp
或者
ps -ef | grep nginx
最保险的还是 浏览器输入 主机ip ,
他显示 nginx 的默认页面
本文来源,作者:fredgui,转载请注明原文链接:https://www.cnblogs.com/guixiaoming/p/6591479.html