我知道这个问题已经被问过好几次了,我甚至在我的公司里做过很多次,但是,现在我想在家里设置一个虚拟主机,但是它不能工作。
我做了什么:
Added xxx.localhost.de into the hosts
127.0.0.1 xxx.localhost.de
Uncommented include vhosts... in my httpd.conf
Include conf/extra/httpd-vhosts.conf
Set up a virtual host for my project
<VirtualHost *:80>
ServerAdmin asdr@web.de
DocumentRoot "D:'wamp'www'xxx"
ServerName xxx.localhost.de
ServerAlias xxx.localhost.de
ErrorLog "logs/xxx-error.log"
CustomLog "logs/xxx-access.log" common
</VirtualHost>
我没有得到一个错误- wamp仍然启动良好,我可以通过使用正常路径访问它localhost/...
但是当我试图通过xxx.localhost.de访问它时,我进入了网站"www.localhost.de"。它表现得好像他不关心我的hosts文件…
我到底错过了什么?在我的公司,事情一直是这样的。我也检查了教程,它总是说这是所有需要的步骤。
谢谢!
我也有同样的问题,有几个事情可以导致,首先尝试添加DirectoryIndex index.php到
<VirtualHost *:80>
ServerAdmin asdr@web.de
DocumentRoot "D:'wamp'www'xxx"
DirectoryIndex index.php
ServerName xxx.localhost.de
ServerAlias xxx.localhost.de
ErrorLog "logs/xxx-error.log"
CustomLog "logs/xxx-access.log" common
</VirtualHost>
,那么你可以试着在你的浏览器中写"http://you_address.local如果这样不行,我再想想别的办法
试试这个:-
将HOSTS文件更改为:-
127.0.0.1 localhost
::1 localhost
127.0.0.1 project1.dev
::1 project1.dev
和Vhost定义到
<VirtualHost *:80>
ServerAdmin asdr@web.de
DocumentRoot "D:'wamp'www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "D:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin asdr@web.de
DocumentRoot "D:'wamp'www'xxx"
ServerName project1.dev
ServerAlias www.project1.dev
ErrorLog "logs/project1-error.log"
CustomLog "logs/project1-access.log" common
<Directory "D:/wamp/www/xxx">
AllowOverride All
Require local
</Directory>
</VirtualHost>
看来我不得不对hosts.ics
文件进行更改,而不是标准的hosts
文件。它工作得很好,然后