当前位置: 移动技术网 > IT编程>开发语言>Java > apache配置基于域名访问

apache配置基于域名访问

2020年07月15日  | 移动技术网IT编程  | 我要评论

编辑配置文件,注释掉directory文件,一共四个

vim /etc/httpd/conf/httpd.conf

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
然后保存退出
检查一下httpd配置文件,ok正常
在这里插入图片描述
创建虚拟主机,编辑文件路径/etc/httpd/conf.d/a123.conf

cd /etc/httpd/conf.d
vi a123.conf

在这里插入图片描述
然后在a123.conf文件里加入这些东西
在这里插入图片描述
可直接复制进去
其中80是端口
DocumentRoot /mnt/z里的 /mnt/z 是默认主页
1.yao.com 是域名(如何在主机上重定向域名
在这里插入图片描述
在这里我创建了两个页面
<Directory “/mnt/z”>
<Directory “/mnt/z/z”>

<VirtualHost *:80>
		DocumentRoot /mnt/z
		ServerName 1.yao.com
	<Directory "/mnt/z">
		Options Indexes FollowSymLinks
		AllowOverride All
		Require all granted
	</Directory>
	<Directory "/mnt/z/z">
		Options Indexes FollowSymLinks
		AllowOverride All
		Require all granted
	</Directory>
</VirtualHost>

创建网站根目录和主文件

mkdir -p /mnt/z/z
echo "hello apache" >/mnt/z/
echo "hello z" >/mnt/z/z/

在这里插入图片描述
验证apache配置文件,通过后重启服务

httpd -t && systemctl restart httpd

在这里插入图片描述在这里插入图片描述在这里插入图片描述

本文地址:https://blog.csdn.net/weixin_45663905/article/details/107334934

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网