linux安装nginx
1.下载nginx源码
安装环境ubuntu
2.安装依赖
首先可以自己检测自己系统是不是已经存在下面的,存在了就跳过对应的安装步骤
wget http://nginx.org/download/nginx-1.10.2.tar.gz(步骤1下载过就忽略)
openssl安装
wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
tar zxvf openssl-fips-2.0.10.tar.gz
cd openssl-fips-2.0.10
./config && make && make install
zlib安装
wget http://zlib.net/zlib-1.2.11.tar.gz
tar zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure && make && make install
pcre安装
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
tar zxvf pcre-8.40.tar.gz
./configure && make && make install
最后nginx 安装
进入相应nginx解压的目录
./configure && make && make install
3.检测安装结果
1查看安装目录
2.执行
报错/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
检测依赖
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)
解决办法上述报错:
whereis libpcre.so.1找到对应的目录,然后执行以下
ln -s /usr/local/lib/libpcre.so.1 /lib(注意这里,有的是/lib64,可以根据上面的ldd的结果)
然后启动nginx(/usr/local/nginx/sbin/nginx),浏览器输入127.0.0.1,ok!