安装包的源地址会时常变化,在wget访问不到的时候可以查询下安装包新的源地址是啥,替换一下即可
step1.检查系统是否安装httpd
rpm -qa|grep httpd
step2.卸载有过httpd的服务
rpm -e --nodeps http*
如果没有使用过,则该命令会返回error,不需要在意
step3.下载Apache最新安装包
wget http://www.eu.apache.org/dist/httpd/httpd-2.4.51.tar.gz
tar zvxf httpd-2.4.51.tar.gz
step4.安装依赖库
yum install pcre-devel -y
yum install zlib-devel -y
yum install openssl-devel -y
yum update openssl
yum install -y libxml2-devel
step4.参考Apache官方安装依赖项
http://httpd.apache.org/docs/2.4/install.html
安装APR and APR-Util
wget http://mirrors.koehn.com/apache//apr/apr-1.7.0.tar.gz
wget http://mirrors.koehn.com/apache//apr/apr-util-1.6.1.tar.gz
wget http://mirrors.koehn.com/apache//apr/apr-iconv-1.2.2.tar.gz
tar zvxf apr-1.7.0.tar.gz
tar zxvf apr-util-1.6.1.tar.gz
tar zxvf apr-iconv-1.2.2.tar.gz
cd apr-1.5.2
查看安装需求
./buildconf
./configure -prefix=/usr/local/apr
如果没有安装gcc库,需要安装gcc库,已安装则跳过这一步
yum install gcc gcc-devel
编译并安装apr
make && make install
cd ..
cd apr-util-1.6.1
./buildconf
查看安装需求
需要指定apr的路径
./configure -prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
此时可能会报错如下
xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录
#include <expat.h>
^
编译中断。
需要安装expat库
yum install -y expat-devel
再次编译安装
make && make install
cd ..
cd apr-iconv-1.2.2
./buildconf
发现依然需要指定apr路径
./configure -prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr
make && make install
安装Apache
cd ..
cd httpd-2.4.51/
./configure --prefix=/usr/local/apache2.4.51 --enable-deflate --enable-expires --enable-headers --enable-modules=most --with-mpm=worker --enable-rewite --enable-so --with-mpm=worker -enable-ssl -with-zlib --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util -with-mpm-event -enable-mpms-shared-all
make && make install
环境变量配置:
sudo vim /etc/bashrc
在文件末尾加上
alias apachectl='/usr/local/apache2.4.51/bin/apachectl'
关闭文件
运行 apachectl start
启动apache
参考链接:
https://blog.csdn.net/m0_46184312/article/details/104003093
https://blog.51cto.com/731434/1351634
http://httpd.apache.org/docs/2.4/install.html
https://blog.csdn.net/dn1115680109/article/details/80847924
https://blog.csdn.net/GilgameshR/article/details/77652419
https://www.xuebuyuan.com/1545532.html
https://blog.51cto.com/castiel/2051440