Apache安装;libpcre错误

48

在安装Apache到Ubuntu 11.10时,我遇到了以下错误:

  

configure: error: APR未找到。请阅读文档。

我按照这里的指示进行操作,但是接下来我又遇到了以下错误:

  

configure: error: 找不到libpcre的pcre-config。需要PCRE,可以从http://pcre.org/获取。

我做错了什么,如何解决?

8个回答

91

1. 从 PCRE.org 下载 PCRE。

2. 使用前缀编译并安装它:

./configure --prefix=/usr/local/pcre
make
make install

3. 回到你的 Apache 安装位置并使用 PCRE 编译 Apache:

--with-pcre=/usr/local/pcre

29
在CentOS 6.3中,我必须显式指定pcre配置文件的位置,例如./configure --with-pcre=/usr/local/pcre/pcre-config - Troy Knapp
httpd的make过程是否会静态链接PCRE?如果我将其打包并分享,是否需要将它们与编译后的httpd一起包含进去? - Nicholas Terry
3
我也有同样的问题,在RHEL 5中需要指定文件完整路径名:--with-pcre=/usr/local/bin/pcre-config。 - Eric
2
Eric,你在评论中拼写config错误浪费了我两个小时的时间x( 请编辑一下。 - MohitC
12
最终在经过数小时后,我的命令 "./configure --with-included-apr --with-pcre=/usr/local/pcre/bin/pcre2-config" 成功了。永不放弃!!! :) - Triven
显示剩余2条评论

18

对于我使用的Fedora Linux系统,只需安装即可:yum install -y pcre-devel。之后甚至不必使用--with-pcre参数。


6
这也适用于Ubuntu。执行sudo apt-get install libpcre3-dev命令(或者根据你在未来的时候所拥有的包/版本进行安装),然后回到之前出现错误的./configure选项中,尝试完全相同的选项。现在应该可以正常工作了。 - daemone
对于 RedHat 6 也可以正常工作。 - Halmackenreuter

10

Debian

在一个干净的 Debian 9.5 安装中,在安装 Apache 时,为避免错误需要安装一些包和库。下面我展示了可能出现的错误类型及其相应的解决方案:

配置

  • configure: error: no acceptable C compiler found in $PATH

    $ sudo apt-get install build-essential

  • configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

    $ sudo apt-get install libpcre3-dev

然后我指定将其安装在路径 /usr/local,而不是 /usr/local/apache2,否则会导致库错误。希望创建 httpd 的库放置在 /usr/local/lib 中,以便动态链接器可以找到它们。

$ configure --prefix /usr/local

编译

在Debian干净安装的过程中,除了要安装一些软件包,还需要进行以下编译操作,以避免出现错误。

  • xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory.

    $ sudo apt-get install libexpat1-dev.

建议使用-j3参数来加速编译,但也可以忽略该参数。

$ make -j3

4

我在CentOS上用pcre编译apache2时遇到了其他问题。我把pcre安装在了另一个位置“/custom/location/pcre”,但配置命令出现了以下错误。

configure: error: Did not find pcre-config script at "/custom/location/pcre"

为解决此问题,需要将标记--with-pcre=/custom/location/pcre更改为--with-pcre=/custom/location/pcre/bin/pcre2-config


1
我曾遇到完全相同的问题,使用命令 ./configure --with-included-apr --with-pcre=/usr/local/pcre/bin/pcre2-config 解决了我的问题 - 不知道为什么会有人对此进行踩负评!! - Yogesh Devi

2

顺便提一下,在构建httpd之前,需要在CentOS 7.6上安装pcre-devel。

`$ sudo yum install pcre-devel` 

你能在这里加一些解释吗,以便更好地理解。 - Shanteshwar Inde

1
在 RHEL 3 中,不必设置参数--with-pcre来指向pcre-config。只需要pcre路径即可。
我的配置命令:
./configure --prefix=/usr/local/apache2 --with-pcre=/usr/local/pcre

谢谢,我刚刚删除了前缀参数中的引号(“)。 - albertoiNET

1
这对我有用: sudo apt-get install libpcre3-dev 在Ubuntu中。

1

这对我有用

./configure --prefix /u01/apache --with-included-apr --with-pcre=/usr/local/pcre/bin/pcre2-config


我还必须直接指向bin中的配置文件。可能是因为我使用了自定义前缀安装了pcre? - Laura

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接