《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
相关推荐
xy123068 天前
OpenStack Train 部署实战(三)控制节点--keystone服务
centos·openstack
欧云服务器11 天前
怎么让脚本命令可以同时在centos、debian、ubuntu执行?
ubuntu·centos·debian
xiaoliuliu1234511 天前
CentOS 7 安装 gcc-4.8.5-44.el7.x86_64.rpm 详细步骤(含依赖解决)
linux·运维·centos
james的分享12 天前
大数据领域核心 SQL 优化框架Apache Calcite介绍
大数据·sql·apache·calcite
莫寒清12 天前
Apache Tika
java·人工智能·spring·apache·知识图谱
归叶再无青12 天前
web服务安装部署、性能升级等(Apache、Nginx)
运维·前端·nginx·云原生·apache·bash
txzz888812 天前
CentOS-Stream-10 Secure Shell服务器sshd_config配置文件
linux·centos·sshd_config·ssh配置
txzz888812 天前
CentOS-Stream-10 Secure Shell服务器
linux·centos·ssh·secure shell·ssh服务器
文静小土豆12 天前
CentOS 7 OpenSSH 10.2p1 升级全攻略(含离线安装与回退方案)
linux·运维·centos·ssh
忙碌54413 天前
OpenTelemetry实战指南:构建云原生全链路可观测性体系
ios·flink·apache·iphone