CentOS安装Httpd

安装方法:

以下文件夹路径是我安装时候使用的,如果你也要安装的话,请根据自己的路径来改就行。下面是避坑安装方法,我安装的时候遇到了很多的坑,快把我安装吐了。

1.到Apache官网下载安装包(https://httpd.apache.org/download.cgi)
在这里插入图片描述
2. 通过共享文件夹或VMware Tools放到CentOS中
3. 通过解压命令解压,(我下的的bz2的)
#tar -jxf httpd-2.4.46.tar.bz2 -C /usr/src/
4.进入到httpd的目录进行安装(我的目录是/usr/src/httpd-2.4.46)
#./configure --prefix=/usr/local/webserver

如果报出类似See “config.log” for more details 的错误,那需要安装C++的编译环境,命令如下
#yum install gcc-c++

5.再执行4的命令,报出APR not found的错误,这个时候需要下载apr(网址下载:http://apr.apache.org/download.cgi)

6.下载完之后,放到虚拟机中,通过#tar -zxf apr-1.7.0.tar.gz -C /usr/src/httpd-2.4.46/srclib/apr ,如果不解压到这个文件夹下面,之后还得通过cp命令拷贝到这个文件夹,重新安装apr。安装命令如下:
#cd apr/
#./configure --prefix=/usr/local/apr
#make && make install

注:如果不能直接解压到上面的文件夹,可以在桌面直接解压,让将解压文件mv到/usr/src/httpd-2.4.46/srclib/apr (前提是压缩包在桌面上),第7同理。

7.安装了这个apr之后,再执行4的命令,又报出error: APR-util not found 的错误。下载网址如5李里提到的。安装过程与6类似。通过#tar -zxf apr-1.7.0.tar.gz /usr/src/httpd-2.4.46/srclib/apr-util。
安装命令如下:
#cd apr-util-1.6.1/
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#make && make install

在这里插入图片描述
8.安装好./configure --prefix=/usr/local/webserver --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/,又报出pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/的错误。
这个需要下载pcre,不是pcre2,如果下载pcre2,就算安装好,还是会报出pcre-config for libpcre not found. PCRE is required的错误。pcre下载网址:https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz

9.下载好,放到虚拟机,通过以下命令安装
#tar -zxf pcre-8.32.tar.gz
#cd pcre-8.32/
#./configure --prefix=/usr/local/pcre
#make; make install

10.回到httpd的目录中,通过以下命令安装
#cd /usr/src/httpd-2.4.46
#./configure --prefix=/usr/local/webserver --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
#make &&make install

11.查看安装是否成功:
进入/usr/local/webserver/,通过ls看到以下文件说明安装成功
在这里插入图片描述

12.启动Apache,
#cd /usr/src/httpd-2.4.46/bin/apachectl start
如果报出
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的错误
那编辑以下文件
#vim /usr/local/webserver/conf/httpd.conf
搜索“#ServerName”
在搜索结果后面添加
ServerName localhost:80

#ServerName www.example.com:80
ServerName localhost:80
在这里插入图片描述

13.关闭SElinux,以下的临时关闭命令,永久关闭请直接百度
setenforce 0

14.最后通过浏览器输入127.0.0.1看到如下结果就结束了。
在这里插入图片描述

补充:
问题:xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory、
解决方法:yum install expat-devel

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值