1、基于IP
2、基于IP+端口
3、基于域名
官网文档:http://httpd.apache.org/docs/2.4/
1、系统环境

2、yum安装


可以查看安装了内容

3、配置Selinux文件,SELINUX=disabled。
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted

或者临时关闭
[root@localhost ~]# setenforce 0
4、关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
5、启动httpd服务,访问测试
[root@localhost ~]# systemctl start httpd

1、查看apache主配置文件,确保存在以下配置,因为等下需要在conf.d/创建虚机主机配置。
[root@localhost ~]# grep "conf.d" /etc/httpd/conf/httpd.conf
IncludeOptional conf.d/*.conf

2、另外,把 Require all denied默认拒绝访问设置为允许访问:Require all granted,方便测试。
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf

1)创建配置文件
[root@localhost ~]# cd /etc/httpd/conf.d/
[root@localhost conf.d]# vim virtual.conf

3)创建虚机主机www的主页面

4)检查配置文件是否正常
[root@localhost conf.d]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK

5)重启httpd服务
[root@localhost conf.d]# systemctl restart httpd

6)打开浏览器,查看结果

1)创建配置文件
[root@localhost ~]# cd /etc/httpd/conf.d/
[root@localhost conf.d]# vim virtual.conf

2)修改httpd主配置文件,在Listen 80下面添加一行监控8080端口
[root@localhost conf.d]# vim /etc/httpd/conf/httpd.conf

3)创建虚机主机a.com和b.com的主页面(如果前面已经创建就不用重复)

4)检查配置文件
[root@localhost conf.d]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
5)重启httpd服务
[root@localhost conf.d]# systemctl restart httpd
6)打开浏览器,查看结果

1)创建配置文件
[root@localhost ~]# cd /etc/httpd/conf.d/
[root@localhost conf.d]# vim virtual.conf

2)修改物理主机hosts文件(C:\Windows\System32\drivers\etc),因为这里是因为物理机去访问Apache服务器
添加:
192.168.253.128 web.com
192.168.253.128 bbs.com

3)物理主机ping域名测试

4)检查配置文件
[root@localhost conf.d]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
5)重启httpd服务
[root@localhost conf.d]# systemctl restart httpd
6)打开浏览器,查看结果

END