CentOS8源码安装httpd 、演示踩坑、填坑
//演示踩坑、填坑
//注意:这种装法是能装上去但是用不了,装到httpd的时候有一大堆问题,想装好Apache、提前把所需的包装好 (*dnf -y install openssl-devel pcre-devel expat-devel *)
//准备工作
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz //安装apr包
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz //安装apr-util
[root@localhost ~]# wget https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz //安装httpd
[root@localhost ~]# tar xf apr-1.7.0.tar.gz //解压
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz //解压
[root@localhost ~]# tar xf httpd-2.4.53.tar.gz //解压
[root@localhost ~]# ls
anaconda-ks.cfg apr-util-1.6.1 httpd-2.4.53.tar.gz
apr-1.7.0 apr-util-1.6.1.tar.gz
apr-1.7.0.tar.gz httpd-2.4.53
源码安装
编译安装Apr
//第一步 ./configure
[root@localhost ~]# cd apr-1.7.0
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr //执行到没有报错为止
//第二步 make
[root@localhost apr-1.7.0]# dnf -y install make //安装make命令
[root@localhost apr-1.7.0]# nproc //查看核心数,
4
[root@localhost apr-1.7.0]# make -j 3 //使用三个CPU核心数编译
//第三步 make install
[root@localhost apr-1.7.0]# make install
编译安装apr-util
//第一步 ./configure
[root@localhost ~]# cd apr-util-1.6.1
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
//第二步 make
[root@localhost apr-util-1.6.1]# make -j 3 //使用三个CPU核心数编译
//第三步 make install
[root@localhost apr-util-1.6.1]# make install
编译安装httpd
//第一步 ./configure
[root@localhost ~]# cd httpd-2.4.53
[root@localhost httpd-2.4.53]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
//第二步 make
[root@localhost httpd-2.4.53]# make -j 3 //使用三个CPU核心数编译
// 第三步make iinstall
[root@localhost httpd-2.4.53]# make install
// 解决报错信息
//解决Apr的报错信息
~执行 ./configure 的时候报错
configure: error: no acceptable C compiler found in $PATH //要安装gcc
See `config.log' for more details
~解决报错
[root@localhost apr-1.7.0]# dnf -y install gcc gcc-c++ //安装gcc、gcc-c++
~执行 ./configure 的时候报的错
rm: cannot remove 'libtoolT': No such file or directory //用 vim configure 编译这个文件里的 # $RM "$cfgfile" //将此行加上注释,或者删除此行
~解决报错
[root@localhost apr-1.7.0]# vim configure
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
$RM "$cfgfile" //将此行加上注释,或者删除此行
cat <<_LT_EOF >> "$cfgfile"
//解决apr-util的报错信息
~执行 ./configure 报的错
xml/apr_xml.c:35:10: fatal error: expat.h: No such file or directory
~解决报错
[root@localhost apr-util-1.6.1]# dnf install -y expat-devel
//解决httpd报错信息
~执行./cconfigure的时候报错
configure: error: pcre(2)-config for libpcre not found. PCRE is required and available from http://pcre.org/
~解决报错
[root@localhost httpd-2.4.53]# dnf -y install pcre-devel
~执行make的时候报的错
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:65: htdbm] Error 1
make[2]: Leaving directory '/root/httpd-2.4.53/support'
make[1]: *** [/root/httpd-2.4.53/build/rules.mk:75: all-recursive] Error 1
make[1]: Leaving directory '/root/httpd-2.4.53/support'
make: *** [/root/httpd-2.4.53/build/rules.mk:75: all-recursive] Error 1
~解决报错
//解决 把前面的Apr和apr-util目录删了重新编译安装。就好了