《HCIP-openEuler实验指导手册》1.7 Apache虚拟主机配置

知识点

配置步骤

  1. 需求
域名 访问目录
test1.com /home/source/test1
test2.com /home/source/test2
test3.com /home/source/test3
  1. 创建配置文件
bash 复制代码
touch /etc/httpd/conf.d/vhost.conf
vim /etc/httpd/conf.d/vhost.conf

文件内容如下

bash 复制代码
<VirtualHost *.81>
ServerName test1.com
DocumentRoot "/home/source/test1"
<Directory "/home/source/test1">
AllowOverride None
#Allow open access:
Require all granted
</Directory>
DirectoryIndex test1.html
</VirtualHost>

<VirtualHost *.81>
ServerName test2.com
DocumentRoot "/home/source/test2"
<Directory "/home/source/test2">
AllowOverride None
#Allow open access:
Require all granted
</Directory>
DirectoryIndex test2.html
</VirtualHost>

<VirtualHost *.81>
ServerName test3.com
DocumentRoot "/home/source/test3"
<Directory "/home/source/test1">
AllowOverride None
#Allow open access:
Require all granted
</Directory>
DirectoryIndex test3.html
</VirtualHost>

将上次实验/etc/httpd/conf.d/source.conf去除

bash 复制代码
cd /etc/httpd/conf.d
mv source.conf source.conf.bak
  1. 准备访问文件
bash 复制代码
echo "this is /test1/test1" > /home/source/test1/test1.html
echo "this is /test2/test2" > /home/source/test2/test2.html
echo "this is /test3/test3" > /home/source/test3/test3.html
systemctl restart httpd
  1. 修改host文件
bash 复制代码
vim /etc/hosts

加入如下内容

127.0.0.1 test1.com

127.0.0.1 test2.com

127.0.0.1 test3.com

  1. 重启服务器测试
bash 复制代码
curl test1.com:81
curl test2.com:81
curl test3.com:81
相关推荐
武子康11 小时前
大数据-259 离线数仓 - Apache Griffin 0.5.0 大数据质量平台:从配置到部署完整指南
大数据·后端·apache
nangonghen12 小时前
centos 7.9安装hiclaw
linux·运维·centos
大明者省12 小时前
CentOS 与 Ubuntu 中 Python 部署的差异
python·ubuntu·centos
IT 行者13 小时前
CentOS 下源码编译安装完整版 Redis 8.0 指南(附 Rust 工具链详解)
redis·rust·centos
D愿你归来仍是少年13 小时前
Apache Flink 学习笔记 · Phase 1
大数据·flink·apache
D愿你归来仍是少年13 小时前
Apache Spark 第 13 章:Real-Time Mode 实时计算
大数据·spark·apache
sthnyph13 小时前
防火墙安全策略(基本配置)
服务器·php·apache
D愿你归来仍是少年14 小时前
Apache Spark 第 13 章 附加篇 · Apache Spark Real-Time Mode 实时计算
大数据·spark·apache
upp1 天前
[最新版本centos 10系统制作与安装]
linux·运维·centos
MX_93591 天前
SpringMVC请求参数
java·后端·spring·servlet·apache