Centos7.4之安装apache及安装过程问题

本文详细介绍了在Centos7.4环境下安装Apache的过程,并针对安装过程中可能遇到的问题,如Apache启动失败、端口冲突及ServerName配置错误等提供了具体的解决方案。

Centos7.4之安装apache及安装过程问题

一、安装httpd

  1. 安装之前,先查看系统中是否存在已经安装了的httpd.rpm包,如果,没有就是没安装,有的话rpm -e 对应的rpm包名进行删除
	#rpm -qa | grep httpd
  1. 使用yum安装(自动安装依赖包),简单方便
	#yum -y install httpd
  1. 安装成功后,httpd-v 查看安装的apache版本,查找apache的配置文件位置
	#find / -name "httpd.conf"
  1. 将找到的源配置文件备份一份,防止错误后无法恢复
	#cp /etc/httpd/conf/httpd.conf	 /etc/httpd/conf/httpd.conf.bak
  1. 启动Apache服务
	#systemctl  start httpd.service
  1. 开机自动启动Apache服务
	#systemctl enable httpd.service 开机自启httpd
	#systemctl disable httpd.service 开机不启动httpd
  1. 查看httpd的状态
	#systemctl status httpd.service

二、安装过程出现的问题

  1. Apache启动失败,Job for httpd.service failed because the control process exited with error code. See “systemctl status httpd.service” and “journalctl -xe” for details

    执行命令,查看报错提示

	#systemctl status httpd.service
[root@cloud1 bin]# systemctl status httpd.service
   httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 五 2018-11-26 11:13:09 CST; 6min ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 9915 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 9913 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 9913 (code=exited, status=1/FAILURE)
 
11月 26 11:13:09 cloud1.localdomain httpd[9913]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
11月 26 11:13:09 cloud1.localdomain httpd[9913]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
11月 26 11:13:09 cloud1.localdomain httpd[9913]: no listening sockets available, shutting down
11月 26 11:13:09 cloud1.localdomain httpd[9913]: AH00015: Unable to open logs
11月 26 11:13:09 cloud1.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
11月 26 11:13:09 cloud1.localdomain kill[9915]: kill: cannot find process ""
11月 26 11:13:09 cloud1.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
11月 26 11:13:09 cloud1.localdomain systemd[1]: Failed to start The Apache HTTP Server.
11月 26 11:13:09 cloud1.localdomain systemd[1]: Unit httpd.service entered failed state.
11月 26 11:13:09 cloud1.localdomain systemd[1]: httpd.service failed.

问题是80端口被占用
解决办法:

	//查看80端口的使用情况
	1.netstat -lnp|grep 80
	
	tcp        0      0 192.168.180.68:61027        0.0.0.0:*                   LISTEN      6289/oproxyd        
	tcp        0      0 :::80                       :::*                        LISTEN      846/httpd           
	tcp        0      0 ::ffff:192.168.180.68:7001 :::*                        LISTEN      32015/java         
	//杀掉占用80端口的进程
	2.kill -9 846
	3.若是前两个方法不行的话,则重启后再启动httpd服务

2.Apache启动失败,httpd:httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain for ServerName

	1.进入apache的配置文件
		vi /etc/httpd/conf/httpd.conf
	2./ServerName 查找ServerName
		#ServerName www.example.com:80
		将其前面的#去掉
		:wq保存并退出
	3.重启服务
		systemctl restart httpd.service
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sheliutao

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值