Apache httpd 源码安装 提示APR错误

1、下载 HTTPD 源码包

https://www.apache.org/

Apache httpd 源码安装 提示APR错误 :解决方法_第1张图片

Apache httpd 源码安装 提示APR错误 :解决方法_第2张图片

Apache httpd 源码安装 提示APR错误 :解决方法_第3张图片

选择 中国域名 cn 的站点:

Apache httpd 源码安装 提示APR错误 :解决方法_第4张图片

找到httpd:

Apache httpd 源码安装 提示APR错误 :解决方法_第5张图片

2、回到Linux CentOS 中 ,使用wget名令下载httpd压缩包:

[root@magedu ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.38.tar.gz
    --2019-07-21 13:16:50--  https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.38.tar.gz
    Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
    Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 9187294 (8.8M) [application/x-gzip]

3、解压 下载文件;

[root@magedu ~]# tar zxvf httpd-2.4.38.tar.gz 
            httpd-2.4.38/
            httpd-2.4.38/config.layout
            httpd-2.4.38/configure.in
            httpd-2.4.38/Makefile.win
            httpd-2.4.38/configure
            httpd-2.4.38/test/
            httpd-2.4.38/test/test_parser.c
            httpd-2.4.38/test/check_chunked
            httpd-2.4.38/test/make_sni.sh
            httpd-2.4.38/test/README
            httpd-2.4.38/test/test-writev.c
            httpd-2.4.38/test/test_limits.c
            httpd-2.4.38/test/tcpdumpscii.txt

4、在解压之前,先安装编译器和开发工具包;

    `   [root@magedu ~]# yum install gcc "Developent Tools"`

5、进到解压的httpd目录,查看 configure 的帮助信息

    [root@magedu ~]# cd httpd-2.4.38/
    [root@magedu httpd-2.4.38]# ./configure --help

6、使用配置文件安装

    [root@magedu httpd-2.4.38]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd
            checking for chosen layout... Apache
            checking for working mkdir -p... yes
            checking for grep that handles long lines and -e... /usr/bin/grep
            checking for egrep... /usr/bin/grep -E
            checking build system type... x86_64-pc-linux-gnu
            checking host system type... x86_64-pc-linux-gnu
            checking target system type... x86_64-pc-linux-gnu
            configure: 
            configure: Configuring Apache Portable(移植) Runtime library(运行库)...
            configure: 
            checking for APR... no
            configure: error: APR not found.  Please read the documentation.(错误:APR没找到,请阅读文档)

提示报错:
configure: error: APR not found. Please read the documentation.(错误:APR没找到,请阅读文档)
提示没有找到 APR,使用yum 来安装,但安装时一定要注意,提示要装哪个软件,一般要在软件的后面加上devel,也就是说要装缺少软件的开发工具,比如这个提示apr,那就要装 apr-devel:

#yum install apr-devel

安装完成之后,再./configure;
特别注意,这个期间不能切换到其他目录中,整个安装的过程一定要在这安装软件的根目录中;

[root@magedu httpd-2.4.38]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd
checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.

提示缺少apr-util,接着安装apr-util的开发版,即 apr-util-devel

root@magedu httpd-2.4.39]# yum install apr-util-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
--> Processing Dependency: libdb-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Running transaction check
...

安装完成之后,再./configure

[root@magedu httpd-2.4.38]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

提示pcre报错,再安装pcre,这个pcre也得装开发版,即安装pcre-devel:

[root@magedu httpd-2.4.39]# yum install pcre-devel -y

安装完成之后,再./configure

# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
...
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:

                 Server Version: 2.4.39
                 C compiler:     gcc -std=gnu99
                CFLAGS:           -pthread  
                CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
               LDFLAGS:           
                 LIBS:             
                 C preprocessor: gcc -E

终于成功了,使用echo$?检查是否成功:

[root@magedu httpd-2.4.39]# echo $?
                    0

然后使用make

[root@magedu httpd-2.4.39]# make
Making all in srclib
make[1]: Entering directory `/soft/httpd-2.4.39/srclib'
make[1]: Leaving directory `/soft/httpd-2.4.39/srclib'
Making all in os

最后:make install
[root@magedu httpd-2.4.39]#make install

7、完成之后,配置PATH变量、man手册,完成后,启动服务,登陆地址,出现测试页,则表示安装成功;

Apache httpd 源码安装 提示APR错误 :解决方法_第6张图片