本文实例讲述了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启动失败,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端口的使用情况
① .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端口的进程
② .kill -9 846
③ .若是前两个方法不行的话,则重启后再启动httpd服务
2.apache启动失败,httpd:httpd: could not reliably determine the server's fully qualified domain name, using localhost.localdomain for servername
① .进入apache的配置文件
vi /etc/httpd/conf/httpd.conf
② ./servername 查找servername
#servername www.example.com:80
将其前面的#去掉
:wq
保存并退出
③ .重启服务
systemctl restart httpd.service
希望本文所述对大家centos服务器配置有所帮助。
如对本文有疑问, 点击进行留言回复!!
网友评论