Linux-CentOS环境下Nginx源码编译安装需要PCRE、OpenSSL、zlib源码包的问题解决
在
nginx
源码编译安装时,可能会碰到缺失
PCRE
、
OpenSSL
、
zlib
源码包文件路径错误的情况,错误例子如下:
[centos@localhost nginx-1.16.1]$ make
make -f objs/Makefile
make[1]: 进入目录“/home/centos/nginx-1.16.1”
cd ../pcre-8.42 \
&& if [ -f Makefile ]; then make distclean; fi \
&& CC="cc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
./configure --disable-shared --enable-jit
/bin/sh: 第 0 行:cd: ../pcre-8.42: 没有那个文件或目录
make[1]: *** [../pcre-8.42/Makefile] 错误 1
make[1]: 离开目录“/home/centos/nginx-1.16.1”
make: *** [build] 错误 2
报这个错误是因为我们在 ./configure
阶段时指定了以下参数:
$ ./configure --with-pcre=../pcre-8.42 \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.1a \
解决方法是需要把对应的文件下载下来,并放到能够查找到的文件内。
先去对应官网将源码包准备好:
PCRE
:https://ftp.pcre.org/pub/pcre/
OpenSSL
:https://www.openssl.org/source/
zlib
:https://www.zlib.net/
通过 wget
命令下载:
$ wget -c https://ftp.pcre.org/pub/pcre/pcre2-10.34.zip
$ wget -c https://www.openssl.org/source/openssl-1.1.1f.tar.gz
$ wget -c https://www.zlib.net/zlib-1.2.11.tar.gz
你可能会想要知道 -c
参数的具体含义,具体了解请参考我的另一篇博客:wget -c 断点续传命令
解压:
$ unzip pcre2-10.34.zip
$ tar -zxvf openssl-1.1.1f.tar.gz
$ tar -zxvf zlib-1.2.11.tar.gz
然后在迁移到你需要的命中的文件路径即可。