apache安装以及报错处理
Centos7.5 编译安装apr-util时报错:xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
解决方案:yum install expat-devel
编译pcre 报错 error: Invalid C++ compiler or C++ compiler flags
解决方案:安装c++ 编译器:yum -y install gcc-c++ ,再次编译通过。
编译安装apach
1.下载准备工具文件并解压
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.28.tar.gz
wget http://mirrors.hust.edu.cn/apache/apr/apr-1.6.3.tar.gz
wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
tar zxvf httpd-2.4.28.tar.gz
tar zxvf apr-util-1.6.1.tar.gz
tar zxvf apr-1.6.3.tar.gz
[root@test_01 apache2.4]# ls /usr/local//src/
apr-1.6.3
apr-1.6.3.tar.gz
apr-util-1.6.1
apr-util-1.6.1.tar.gz
httpd-2.4.28
httpd-2.4.28.tar.gz
mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
2.编译安装apr和apr-util
apr和apr-util通用的函数库,apache依赖与这两个函数库。
cd /usr/local/src/apr-1.6.1
./configure --prefix=/usr/local/apr
make && make install
cd /usr/local/src/apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
在编译过程中出现了如下错误:
错误①
configure: error: no acceptable C compiler found in $PATH
出现该错误是因为没有安装gcc套件,yum安装后解决问题。
[root@test_01 apache2.4]# yum install -y gcc
错误②
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
yum安装pcre-devel包后解决
yum install -y pcre-devel
3.编译安装httpd
cd /usr/local/src/httpd-2.4.27
./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
编译过程中都正常,但是make&&make install 的时候出现了如下错误
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserCreate'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserFree'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetUserData'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_StopParser'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_Parse'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ErrorString'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory `/usr/local/httpd-2.4.26/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/httpd-2.4.26/support'
make: *** [all-recursive] Error 1
原因:该错误是因为缺少了xml相关的库,导致reference无效
解决方法:
①安装libxml2-devel
[root@test_01 ~]# yum install -y libxml2-devel
②删除apr-util目录并且重新编译安装
[root@test_01 ~]#rm -rf /usr/local/apr-util
[root@test_01 ~]# cd /usr/local/src/apr-util-1.6.1/
[root@test_01 apr-util-1.6.1]# make clean
[root@test_01 apr-util-1.6.1]#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@test_01 apr-util-1.6.1]#make && make install
③重新编译安装httpd,成功解决。