yum install -y gcc gcc-c++
需准备的软件包有:
下载地址: https://httpd.apache.org/download.cgi#apache24
下载地址: https://apr.apache.org/download.cgi
下载地址:https://sourceforge.net/projects/pcre/files/pcre/
解压: tar -zxf apr-1.7.0.tar.gz
;
进入解压目录: cd apr-1.7.0
配置: ./configure --prefix=/usr/local/apr
;
–prefix是指定安装目录(如果目录不存在会自动生成)
编译: make
;
如果编译失败了需要重新编译的话,需要先执行
make clean
安装: sudo make install
;
安装命令需要有足够的权限,否者会安装失败
解压: tar -zxf apr-util-1.6.1.tar.gz
;
进入解压目录: cd apr-util-1.6.1
配置: ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
;
编译: make
;
安装: sudo make install
;
注意:
编译安装apr-util如果显示错误:
fatal error: expat.h: No such file or directory
需要准备一个expat
软件包进行编译安装,然后再编译安装ARP-Util
.
expat下载地址:https://github.com/libexpat/libexpat/releases
expat编译安装:
1.解压: tar -xvjf expat-2.4.3.tar.bz2 2.进入解压目录: cd expat-2.4.3 3.配置: ./configure --prefix=/usr/local/expat 4.编译: make 5.安装: sudo make install
ARP-Util编译安装:
1.解压: tar -zxf apr-util-1.6.1.tar.gz; 2.进入解压目录: cd apr-util-1.6.1 3.配置: ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config --with-expat=/usr/local/expat; 注意此处多了一个--with-expat 4.编译: make; 5.安装: sudo make install;
1.解压: tar -zxvf pcre-8.45.tar.gz 2.进入解压目录: cd pcre-8.45 3.配置: ./configure --prefix=/usr/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config 4.编译: make 5.安装: sudo make install
1.解压: tar -zxvf httpd-2.4.52.tar.gz 2.进入解压目录: cd httpd-2.4.52 3.配置: ./configure --prefix=/usr/local/apache --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util 4.编译: make 5.安装: sudo make install
/usr/local/apache/bin/apachectl start
/usr/local/apache/bin/apachectl stop
将以下安装目录删除:
/usr/local/apr /usr/local/expat /usr/local/apr-util /usr/local/pcre /usr/local/apache
附:
参考文章:
1.https://www.cnblogs.com/wcwnina/p/8029156.html
2.https://stackoverflow.com/questions/54412872/apache-httpd-build-from-source-fatal-error-expat-h-no-such-file-or-directory
3.https://www.cnblogs.com/tinywan/p/7230039.html