1、下载安装包wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.37.tar.gz
2、解压tar zxvf httpd-2.4.37.tar.gz
3、进入目录cd httpd-2.4.37/
4、./configure --prefix=/usr/local/apache2/ --enable-rewrite --enable-so
5、出现提示not found APR
6、卸载系统上原有的apr apr-utl
7、yum remove apr apr-util
8、下载新的apr、apr-util安装wget http://mirror.bit.edu.cn/apache//apr/apr-1.6.5.tar.gz wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
9、./configure --prefix=/usr/local/apr;make;make install
10、./configure --prefix=/usr/local/apr-util;make make的时候出现错误[xml/apr_xml.lo]错误
11、解决方法yum install expat-devel 继续安装apr-util make clean;make;make install
12、继续回到第4步编译,当还是提示找不到apr或apr-util时,configure执行时直接指定路径./configure --prefix=/usr/local/apache2/ --enable-rewrite --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
13、make && make install
14、关闭selinux、防火墙等,开启Apache服务
15、开启过程中提示httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message。编辑httpd.conf文件,将ServerAdmin you@example.com前的注释去掉。编辑/etc/hosts文件,将第一个localhost改为服务器主机名。
16、重启Apache服务
如果make apache时报错如下
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] 错误 1
make[2]: 离开目录“/usr/local/src/httpd-2.4.27/support”
make[1]: *** [all-recursive] 错误 1
make[1]: 离开目录“/usr/local/src/httpd-2.4.27/support”
make: *** [all-recursive] 错误 1
则将解压出来的apr和apr-util目录移至/httpd-2.4.27/srclib/目录
然后重新编译安装apr和apr-util