启用虚拟主机后,Wamp目录无法正常工作
I have created a virtual host for a new application in wamp.
In my httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf //<--- Removed #
In my httpd.vhosts.conf
I added a new host
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/wamp/www/myapp"
ServerName myapp.local
ServerAlias 127.0.0.1
SetEnv APPLICATION_ENV "development"
<Directory "C:/wamp/www/myapp/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
</Directory>
</VirtualHost>
The virtual host is working fine. But the problem is my other apps that run without virtual hosts are not working.
When i open http://localhost/fistapp/
it shows
Forbidden 403
You don't have permission to access / on this server.
我已经为wamp中的新应用程序创建了一个虚拟主机。 p>
在我的 在我的 当我打开 httpd.conf code> p>
#Virtual hosts
Include conf / extra / httpd-vhosts.conf //&lt; --- Removed#\ n code> pre>
httpd.vhosts.conf code>中我添加了一个新主机 p>
&lt ; VirtualHost *:80&gt;
ServerAdmin webmaster @ localhost
DocumentRoot“C:/ wamp / www / myapp”
ServerName myapp.local
ServerAlias 127.0.0.1
SetEnv APPLICATION_ENV“development”
&lt; Directory“ C:/ wamp / www / myapp /“&gt;
选项索引FollowSymLinks MultiViews
AllowOverride all
&lt; / Directory&gt;
&lt; / VirtualHost&gt;
code> pre>
虚拟主机工作正常。 但问题是我在没有虚拟主机的情况下运行的其他应用程序无效。 p>
http:// localhost / fistapp / code>时显示 p >
Forbidden 403
您无权访问此服务器上的/。
code> pre>
div>
Once you create a Virtual Host definition Apache basically ignores the localhost domain defined in the httpd.conf
file, so you have to also define locahost in the httpd-vhosts.conf
file as well. So your httpd-vhosts.conf
file should look like this :
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
# made some amendments to this VH as well
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/myapp"
ServerName myapp.local
# not sure why this is here ServerAlias 127.0.0.1
ServerAlias www.myapp.local
SetEnv APPLICATION_ENV "development"
<Directory "C:/wamp/www/myapp">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride all
Require local
</Directory>
</VirtualHost>
Dont forget to amend the C:\windows\system32\drivers\etc\hosts
file to add your new domain like this
127.0.0.1 localhost
::1 localhost
127.0.0.1 myapp.local
::1 myapp.local