目录
1.指定IP地址与域名之间的对应关系的配置
2.使用ping命令检查域名解析是否正确
3. 创建存放不同网站的根目录,并写入网站首页内容
4.修改主配置文件
5.重启httpd服务
6.修改自定义网站目录的Selinux文件安全上下文
7. 刷新Selinux安全上下文,使其立即生效
8.使用域名测试网站,检查网站是否能正常打开
vim /etc/hosts
注:192.168.20.73是我的主机的IP地址
mkdir -p /home/yuming/aaa
mkdir -p /home/yuming/bbb
mkdir -p /home/yuming/ccc
echo "我的网站域名是www.aaa.com" > /home/yuming/aaa/index.html
echo "我的网站域名是www.bbb.com" > /home/yuming/bbb/index.html
echo "我的网站域名是www.ccc.com" > /home/yuming/ccc/index.html
vim /etc/httpd/conf/httpd.conf
将下列内容写入配置文件(IP地址需要改成自己的IP地址)
DocumentRoot /home/yuming/aaa
ServerName www.aaa.com
AllowOverride None
Require all granted
DocumentRoot /home/yuming/bbb
ServerName www.bbb.com
AllowOverride None
Require all granted
DocumentRoot /home/yuming/ccc
ServerName www.ccc.com
AllowOverride None
Require all granted
systemctl restart httpd
semanage fcontext -a -t httpd_sys_content_t /home/yuming
semanage fcontext -a -t httpd_sys_content_t /home/yuming/aaa
semanage fcontext -a -t httpd_sys_content_t /home/yuming/aaa/*
semanage fcontext -a -t httpd_sys_content_t /home/yuming/bbb
semanage fcontext -a -t httpd_sys_content_t /home/yuming/bbb/*
semanage fcontext -a -t httpd_sys_content_t /home/yuming/ccc
semanage fcontext -a -t httpd_sys_content_t /home/yuming/ccc/*
restorecon -Rv /home/yuming