一.基于域名的虚拟主机的配置
1.记事本打开hosts文件,该文件在:C:\ Windows\ System32\ drivers\etc这个文件夹下, 在文件内容的末尾写入如下内容:
127.0.0.1 www.lamp1018.com 作用:在hosts文件中将访问地址指向本地
出现You don't have permission to access / on this server时,是因为我的虚拟主机目录为非apache安装目录下的htdocs,所以违反了apache默认对网站根访问权限。
apache的默认虚拟主机根目录地址为../Apache24/htdocs 目录下,需要对httpd.conf文件进行修改才能指向其他目录。
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride All
Require all denied
</Directory>
修改为
<Directory />
AllowOverride All
Require all granted
</Directory>