虚拟主机功能

方式一:基于IP地址

在本机配置3个IP

nmtui

# 192.168.1.100/24
# 192.168.1.101/24
# 192.168.1.102/24

# 配置好后重启网络
# ping一下3个IP,确保IP均可正常访问

创建网站目录及首页文件

mkdir -p /home/wwwroot/100
mkdir -p /home/wwwroot/101
mkdir -p /home/wwwroot/102

echo "IP: 192.168.1.100" > /home/wwwroot/100/index.html
echo "IP: 192.168.1.101" > /home/wwwroot/101/index.html
echo "IP: 192.168.1.102" > /home/wwwroot/102/index.html

编辑httpd服务的配置文件

配置SELinux上下文

重启httpd服务

访问测试

方式二:基于主机域名

配置解析文件

创建网站目录及首页文件

编辑httpd服务的配置文件

配置SELinux上下文

重启httpd服务

访问测试

方式三:基于端口号

创建网站目录及首页文件

编辑httpd服务的配置文件

配置SELinux上下文

配置SELinux域

重启httpd服务

访问测试

Last updated