在CentOS7上编译安装apache 2.4源码包,并启动此服务

一.安装开发软件包组

[root@localhost yum.repos.d]#yum groupinstall "development tools"

在这里插入图片描述

[root@localhost yum.repos.d]# yum install openssl-devel

[root@localhost yum.repos.d]# yum install pcre-devel

[root@localhost yum.repos.d]# yum install expat-devel

二.检查httpd是否已经安装

[root@localhost yum.repos.d]# rpm -qa httpd

如果没有返回信息,则代表没有安装

三.安装Apache

1.通过 以下命令从网络中下载httpd-2.4.38.tar.gz包,放置在家目录下

[root@localhost ~]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.38.tar.gz

在这里插入图片描述
2.解压当前文件,使用命令:

[root@localhost ~]# tar zxvf httpd-2.4.34.tar.gz 

3.配置configure脚本

[root@localhost httpd-2.4.38]# ./configure 
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.

最后一行提示报错,缺少ARP需要安装,apr是Apache Portable Runtime的缩写,中文译为Apache可移植运行环境,是httpd所必须的,apr-util同理。

apr及apr-util下载地址:http://apr.apache.org/download.cgi

wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz

再进行解包和解压:

[root@localhost ~]# tar -zxvf apr-1.7.0.tar.gz
[root@localhost ~]# tar -zxvf apr-util-1.6.1.tar.gz 

再安装apr和apr-util

[root@localhost ~]#cd apr-1.7.0 
[root@localhost apr-1.7.0]#./configure
[root@localhost apr-1.7.0]#make && make install

[root@localhos local]# cd apr-util-1.6.1
[root@localhos apr-util-1.6.1]# ./configure --with-apr=/usr/local/apr/
[root@localhos apr-util-1.6.1]# make && make install

重新安装httpd服务

[root@localhost httpd-2.4.38]# ./configure

在这里插入图片描述

[root@localhost httpd-2.4.38]# make && make install

四.检查

[root@localhost ~]#  cd /usr/local/apache2
[root@localhost apache2]# apachectl -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK

提示了一个错误,需要编辑httpd.conf文件,如下:

[root@localhost apache2]# cd conf
[root@localhost conf]# vim httpd.conf 

编辑httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80
在这里插入图片描述
再次检查是否还有错误:

[root@localhost apache2]# apachectl -t
Syntax OK

最后启动服务:

[root@localhost apache2]# apachectl start

在浏览器输入本机网址,出现如下图,则代表安装成功了:
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值