检查Apache工作状态
确认Apache正常工作, apache的版本已经安装路径。
[root@centos7 ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Apr 24 2019 13:45:48
[root@centos7 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2020-06-15 16:46:36 CST; 5min ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 6506 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Tasks: 272
Memory: 31.3M
CGroup: /system.slice/httpd.service
├─6506 /usr/sbin/httpd -DFOREGROUND
├─6592 /usr/sbin/httpd -DFOREGROUND
├─6607 /usr/sbin/httpd -DFOREGROUND
├─6608 /usr/sbin/httpd -DFOREGROUND
├─6609 /usr/sbin/httpd -DFOREGROUND
├─6610 /usr/sbin/httpd -DFOREGROUND
├─6611 /usr/sbin/httpd -DFOREGROUND
├─6612 /usr/sbin/httpd -DFOREGROUND
├─6613 /usr/sbin/httpd -DFOREGROUND
├─6622 /usr/sbin/httpd -DFOREGROUND
├─6623 /usr/sbin/httpd -DFOREGROUND
└─6633 /usr/sbin/httpd -DFOREGROUND
Jun 15 16:46:36 centos7 systemd[1]: Starting The Apache HTTP Server...
Jun 15 16:46:36 centos7 systemd[1]: Started The Apache HTTP Server.
[root@centos7 ~]#
确认httpd.conf的位置。 在CentOS7中此位置为/etc/httpd/conf, 其他linux系统可能有其他位置, 如果不确认,可以使用 find命令寻找.
[root@centos7 ~]# ll /etc/httpd/conf
total 56
-rw-r--r-- 1 root root 890 Jun 26 2019 healthshare.conf
-rw-r--r-- 1 root root 0 Jun 26 2019 healthshare.conf_save
-rw-r--r-- 1 root root 11786 Jun 30 2019 httpd.conf
-rw-r--r-- 1 root root 11753 Jun 26 2019 httpd.conf.bak
-rw-r--r-- 1 root root 11746 Jun 30 2019 httpd.conf2
-rw-r--r-- 1 root root 13077 Apr 24 2019 magic
[root@centos7 ~]#
从Caché所在服务器用浏览器检查Apache测试页面可以访问。如果在Apache本地服务器访问, 网址为127.0.0.1(如果远端无法访问,请首先检查防火墙,后面步骤中有介绍)
picture testing123
关闭SELinux配置
查询确认SELinux状态为disabled
[root@centos7 ~]# getenforce
Disabled
如果非disabled状态,需要修改配置文件实现, 下图为修改后的文件内容,修改后重启电脑生效。
[root@centos7 ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@centos7 ~]#
检查防火墙
确认apache所在服务器的防火墙打开了80端口。(为简化步骤, 这里不讨论Web Server的SSL接入)
[root@centos7 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2020-06-15 17:24:15 CST; 2s ago
Docs: man:firewalld(1)
Main PID: 27433 (firewalld)
Tasks: 2
Memory: 25.1M
CGroup: /system.slice/firewalld.service
└─27433 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Jun 15 17:24:15 centos7 systemd[1]: Starting firewalld - dynamic firewall daemon...
Jun 15 17:24:15 centos7 systemd[1]: Started firewalld - dynamic firewall daem