bash 使用 pcre 和 openssl 从源代码安装 NGINX 在 make 上引发错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34774315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 14:06:16  来源:igfitidea点击:

Installing NGINX from source with pcre and openssl throws error on make

linuxbashubuntunginx

提问by Obinwanne Hill

I'm attempting to install NGINX from source on Ubuntu 14.04.3 LTS [via DigitalOcean] but I'm having issues during the makeprocess.

我正在尝试在 Ubuntu 14.04.3 LTS [通过 DigitalOcean] 上从源代码安装 NGINX,但我在制作过程中遇到了问题。

Here is my bash script:

这是我的 bash 脚本:

wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar xzf nginx-1.8.0.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.20.tar.gz
tar xzf pcre2-10.20.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
tar xzf zlib-1.2.8.tar.gz
wget https://openssl.org/source/openssl-1.0.2e.tar.gz
tar xzf openssl-1.0.2e.tar.gz
cd nginx-1.8.0
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/etc/nginx.conf --user=nginx --group=nginx --with-http_ssl_module --with-pcre=/root/src/pcre2-10.20 --with-zlib=/root/src/zlib-1.2.8 --with-openssl=/root/src/openssl-1.0.2e
make

I get the following errors:

我收到以下错误:

make[2]: Entering directory `/root/src/pcre2-10.20'
make[2]: *** No rule to make target `libpcre.la'.  Stop.
make[2]: Leaving directory `/root/src/pcre2-10.20'
make[1]: *** [/root/src/pcre2-10.20/.libs/libpcre.a] Error 2
make[1]: Leaving directory `/root/src/nginx-1.8.0'
make: *** [build] Error 2

I checked the gcc version using gcc -vand it says 4.8.4.

我使用检查了 gcc 版本gcc -v,它说 4.8.4。

How can I fix this?

我怎样才能解决这个问题?

UPDATE

更新

It turns out that the PCRE version I was using was the wrong one, so I changed to version 1 and everything worked. Here's the updated bash script:

事实证明,我使用的 PCRE 版本是错误的,所以我更改为版本 1,一切正常。这是更新后的 bash 脚本:

wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar xzf nginx-1.8.0.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
tar xzf pcre-8.38.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
tar xzf zlib-1.2.8.tar.gz
wget https://openssl.org/source/openssl-1.0.2e.tar.gz
tar xzf openssl-1.0.2e.tar.gz
cd nginx-1.8.0
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/etc/nginx.conf --user=nginx --group=nginx --with-http_ssl_module --with-pcre=/root/src/pcre-8.38 --with-zlib=/root/src/zlib-1.2.8 --with-openssl=/root/src/openssl-1.0.2e
make

Thanks to @EtanReiser for the find.

感谢@EtanReiser 的发现。

回答by Etan Reisner

You are using the wrong version of PCRE.

您使用的 PCRE 版本错误。

You are trying to use the PCRE2 version of the library but nginx requires the PCRE version of the library.

您正在尝试使用该库的 PCRE2 版本,但 nginx 需要该库的 PCRE 版本。

From the docs:

文档

--with-pcre=path— sets the path to the sources of the PCRE library. The library distribution (version 4.4 — 8.32) needs to be downloaded from the PCREsite and extracted. The rest is done by nginx's ./configureand make. The library is required for regular expressions support in the locationdirective and for the ngx_http_rewrite_modulemodule.

--with-pcre=path— 设置 PCRE 库源的路径。需要从PCRE站点下载并提取库分发(版本 4.4 — 8.32)。其余的由 nginx./configuremake. location指令和ngx_http_rewrite_module模块中的正则表达式支持需要该库。