编译安装apache
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了编译安装apache相关的知识,希望对你有一定的参考价值。
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
[[email protected]_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安装后解决问题。
[[email protected]_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
[[email protected]_01 ~]# yum install -y libxml2-devel
②删除apr-util目录并且重新编译安装
[[email protected]_01 ~]#rm -rf /usr/local/apr-util [[email protected]_01 ~]# cd /usr/local/src/apr-util-1.6.1/ [[email protected]_01 apr-util-1.6.1]# make clean [[email protected]_01 apr-util-1.6.1]#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr [[email protected]_01 apr-util-1.6.1]#make && make install
③重新编译安装httpd,成功解决。
以上是关于编译安装apache的主要内容,如果未能解决你的问题,请参考以下文章
Android 逆向Android 逆向通用工具开发 ( Android 平台运行的 cmd 程序类型 | Android 平台运行的 cmd 程序编译选项 | 编译 cmd 可执行程序 )(代码片段