在我创build一个虚拟主机之前,我可以看到“ http:// localhost ”,但是当我创build一个虚拟主机时,我看不到“ http:// localhost ”和虚拟主机“ http:// test ”
这是我的虚拟主机configuration文件:
<VirtualHost test:80> ServerAdmin [email protected] ServerName test ServerAlias test DocumentRoot "/home/javad/Public/test/public" <Directory "/home/javad/Public/test/public/" > Options Indexes FollowSymLinks MultiViews ExecCGI DirectoryIndex index.php AllowOverride all Order allow,deny allow from all </Directory> </VirtualHost>
所以我跑了2场testing
并补充说
127.0.0.1testing到/ etc / hosts文件并重新启动apapche2
但之后,我无法访问http://testing甚至http:// localhost我得到
Forbidden You don't have permission to access / on this server.
当我删除我的虚拟主机设置时,我可以访问http:// localhost
一旦激活虚拟主机,您需要将localhost重新configuration为虚拟主机。 您可以简单地复制粘贴httpd.conf参数。
目录和目录列表中可能没有索引文件被禁用? – 你不能直接访问文件?
否则请检查Web服务器用户的读取权限。
在虚拟主机容器中有一个目录expression式,看起来很奇怪,通常情况下不是这样,如果你能启动你的web服务器,它似乎工作。
您需要有一个名为virtualvirtualhost指令,以使您的configuration正常工作。
<VirtualHost test:80> …尝试使用*:80或ip:80代替。 解决scheme可能会导致问题,并使虚拟主机无效。
这太长了评论,所以这是我会修改的答案。 运行这个脚本并向我们提供输出:
#!/bin/bash -x -e cd / ls -lhd . cd home ls -lhd . cd javad ls -lhd . cd Public ls -lhd . cd test ls -lhd . cd public ls -lhd . ls -lh
当你创build一个虚拟主机的时候,你也必须为你的服务器指定一个虚拟主机,在这种情况下是localhost。 看到标题为“ 主人走开 ”的高亮部分