安装gcc和gcc-c++, 使用yum install gcc-c++
准备 apr下载地址:http://apr.apache.org/download.cgi
准备 apr-util下载地址:http://apr.apache.org/download.cgi
准备 pcre 下载地址:http://pcre.org/
准备 apache下载地址:http://httpd.apache.org/download.cgi
检查是否存在pcre-devel, 如果不存在, 使用yum install pcre-devel.x86_64安装
解压 apr, apr-util, pcre
tar -zxvf apr-1.5.2.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
tar -zxvf pcre-8.40.tar.gz
将解压后的文件夹移动到 httpd-2.4.25下的srclib中(这种安装方式就不能查找到apr, apr-util, pcre了)
mv apr-1.5.2 httpd-2.4.25/srclib/apr
mv apr-util-1.5.4 httpd-2.4.25/srclib/apr-util
mv pcre-8.40 httpd-2.4.25/srclib/pcre
移动到httpd源码路径下
cd httpd-2.4.25
执行配置 ./configure --prefix=/usr/httpd
make
make install
安装之后设置开机自启
cp /usr/httpd/bin/apachectl /etc/init.d/httpd
systemctl enable httpd
如果提示:
httpd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig httpd on
service httpd does not support chkconfig
编辑/etc/init.d/httpd文件
在第二行加上以下两句
#chkconfig:345 85 15
#description:Start and stop the Apache HTTP Server
启动服务systemctl start httpd.service
查看服务状态systemctl status httpd.service
开放防火墙端口
firewall-cmd --add-port=80/tcp --permanent --zone=public
firewall-cmd --reload
最后访问一下http://ip:port/