yum安装apache

参考文章:https://blog.csdn.net/yishuifengxiao/article/details/80557747

跟我自己的linux上yum安装Apache遇到的问题是一样的。

检查linux上是否已经安装了Apache

Apache在linux上的服务名称是httpd。如果已经安装有Apache,那么就会有信息提示;如果没有装有,那么就没有信息:

#yum list installed |grep httpd

 

或者#rpm -qa|grep httpd

以上两个图都表示未安装有Apache。

②安装Apache

#yum -y install httpd  安装Apache

安装完成之后,再使用命令查询:

#yum list installed |grep httpd或者  #rpm -qa |grep httpd,如下图所示,表示已经安装成功

启动Apache

 #service httpd start,如图所示,启动失败

 

④问题描述:

问题一

正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

问题二

(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

⑤解决问题:

问题一解决方案:

a、编辑/etc/httpd/conf路径下的http.conf文件:#vi /etc/httpd/conf/httpd.conf

 b、在#ServerName www.example.com:80这一行的下面添加ServerName localhost:80

 

c、保存退出,重启Apache:#service httpd restart

 ok,如上图所示,问题一已经解决,现在就只剩下问题二了

问题二解决方案:

a.从问题二的描述中可以看出,是因为80端口被占用了,无法绑定80端口。

b.修改/etc/httpd/conf/httpd.conf,将Listen  80设置成一个没有被使用的端口,例如83。

c.保存退出,启动Apache

如下图,又出现了新的问题,还不能启动。

d. 禁用SElinux

●禁用SELINUX的前提条件是 SELINUXTYPE=targeted ,方法是##cat /etc/selinux/config|grep SELINUXTYPE

●编辑/etc/selinux/config文件,找到SELINUX=enforcing,然后将其修改为SELINUX=disable

 

●保存退出,重启linux系统

⑥reboot之后再启动

#service httpd start

如图所示,表示Apache可以正常启动了

⑦访问浏览器,记得加上端口号,终于可以正常访问了。

 至此,linux上yum安装Apache总算完成了。

原文地址:https://www.cnblogs.com/yyl6/p/11216516.html