大家好,又见面了,我是你们的朋友全栈君。
已安装好Apache的服务器环境。
打开httpd.conf文件,根据安装目录找到该文件。我的在D:\apache24\conf\目录下。
找到#LoadModule vhost_alias_module modules/mod_vhost_alias.so,去掉最前面的“#”来启用apache的虚拟主机功能。
DocumentRoot和Directory,改为站点目录的上一级目录
例如站点放在 D:/Appserv/www/1 和 D:/Appserv/www/2,则改为以下形式
DocumentRoot "D:/Appserv/www"
<Directory "D:/Appserv/www">
找到#Include conf/extra/httpd-vhosts.conf,去掉最前面的“#”。
编辑httpd.conf文件同级目录下的extra目录下的httpd-vhosts.conf文件,修改虚拟目录配置,如下所示。(注:顺序绝不可以乱,127.0.0.1这组必须为第一组,否则会出现localhost不能访问的问题)
<VirtualHost *:80>
DocumentRoot "D:/Apache24/htdocs"
ServerName 127.0.0.1
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/Apache24/htdocs/test
ServerName test.com
</VirtualHost>
END
注意安装目录不同,配置文件的目录也不相同。
编辑httpd-vhosts.conf文件时,127.0.0.1的配置必须写在第一组,否则localhost作为域名访问站点时会提示not found。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/106426.html原文链接:https://javaforall.cn
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有