apache配置虚拟目录和主机

本文介绍如何在Apache服务器上配置虚拟目录和虚拟主机,包括编辑httpd.conf及httpd-vhosts.conf文件来实现不同站点的管理和访问。通过设置访问权限、欢迎页面等参数,确保网站稳定运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

配置虚拟目录
1.在在 httpd.conf 文件中 
<IfModule dir_module>
#direcotory相当于是欢迎页面
DirectoryIndex index.html index.htm index.php
#你的站点别名
Alias /notebook "D:/notebook"
<Directory d:/notebook>
#这是访问权限设置
Order allow,deny
Allow from all
</Directory> 
</IfModule>
DocumentRoot "C:/AppServ/apache/htdocs"
2.注销documentroot路径
#DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
3.测试
http://localhost/notebook/index.html 




配置虚拟主机
1.启用  httpd-vhosts.conf
在 httpd.conf 文件中 
# Virtual hosts ,虚拟主机
Include conf/extra/httpd-vhosts.conf
2.在httpd-vhosts.conf文件中做配置
<VirtualHost127.0.0.1:80>
DocumentRoot "d:/notebook"
#这里配置欢迎首页面
DirectoryIndex index.html index.htmindex.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


3.修改hosts 文件 ->新的知识点. (重新审视我们的访问一个网页的真正流程)
127.0.0.1notebook.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值