redhat7手动安装apache


安装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 enable httpd


启动服务systemctl start httpd.service
查看服务状态systemctl status httpd.service


开放防火墙端口

firewall-cmd --add-port=80/tcp --permanent --zone=public

firewall-cmd --reload


最后访问一下http://ip:port/





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值