扣丁学堂Linux培训之Centos7.4服务器安装apache及安装过程出现的问题解决方法

2019-04-30 14:16:14 1492浏览

今天扣丁学堂Linux培训老师给大家分享一篇关于Centos7.4服务器安装apache及安装过程出现的问题解决方法,结合实例形式分析了Centos7.4服务器安装apache相关命令、配置操作及端口占用等常见问题解决方法,分享给大家供大家参考,具体如下:



一、安装httpd

1.安装之前,先查看系统中是否存在已经安装了的httpd.rpm包,如果,没有就是没安装,有的话rpm-e对应的rpm包名进行删除

#rpm -qa | grep httpd

2.使用yum安装(自动安装依赖包),简单方便

#yum -y install httpd

3.安装成功后,httpd-v查看安装的apache版本,查找apache的配置文件位置

#find / -name "httpd.conf"

4.将找到的源配置文件备份一份,防止错误后无法恢复

#cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak

5.启动Apache服务

#systemctl start httpd.service

6.开机自动启动Apache服务

#systemctl enable httpd.service 开机自启httpd
#systemctl disable httpd.service 开机不启动httpd

7.查看httpd的状态

#systemctl status httpd.service


二、安装过程出现的问题

1.Apache启动失败,Jobforhttpd.servicefailedbecausethecontrolprocessexitedwitherrorcode.See“systemctlstatushttpd.service”and“journalctl-xe”fordetails

执行命令,查看报错提示

#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端口的使用情况

①.netstat-lnp|grep80

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端口的进程

②.kill-9846

③.若是前两个方法不行的话,则重启后再启动httpd服务

2.Apache启动失败,httpd:httpd:Couldnotreliablydeterminetheserver'sfullyqualifieddomainname,usinglocalhost.localdomainforServerName

①.进入apache的配置文件

vi /etc/httpd/conf/httpd.conf

②./ServerName查找ServerName

#ServerName www.example.com:80

将其前面的#去掉

:wq保存并退出

③.重启服务

systemctl restart httpd.service

以上就是关于扣丁学堂Linux培训之Centos7.4服务器安装apache及安装过程出现的问题解决方法的详细介绍,想要了解更多关于Linux开发方面内容的小伙伴,请关注扣丁学堂Linux培训官网、微信等平台,扣丁学堂IT职业在线学习教育有专业的Linux讲师为您指导,此外扣丁学堂老师精心推出的Linux视频教程定能让你快速掌握Linux从入门到精通开发实战技能。扣丁学堂Linux技术交流群:422345477。


                          【扫码进入HTML5VIP免费公开课】  


     【关注微信公众号获取更多学习资料】        【扫码进入HTML5前端开发VIP免费公开课】



查看更多关于“Linux培训资讯”的相关文章>>

标签: Linux培训 Linux视频教程 红帽Linux视频 Linux学习视频 Linux入门视频

热门专区

暂无热门资讯

课程推荐

微信
微博
15311698296

全国免费咨询热线

邮箱:codingke@1000phone.com

官方群:148715490

北京千锋互联科技有限公司版权所有   北京市海淀区宝盛北里西区28号中关村智诚科创大厦4层
京ICP备12003911号-6   Copyright © 2013 - 2019

京公网安备 11010802030908号