启用虚拟主机后 Wamp 目录不工作
Wamp directories not working after enabling virtual host
我已经在 wamp 中为新应用程序创建了一个虚拟主机。
在我的httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf //<--- Removed #
在我的 httpd.vhosts.conf
我添加了一个新主机
<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>
虚拟主机工作正常。但问题是我的其他 运行 没有虚拟主机的应用程序无法运行。
当我打开 http://localhost/fistapp/
时显示
Forbidden 403
You don't have permission to access / on this server.
创建虚拟主机定义后,Apache 基本上会忽略 httpd.conf
文件中定义的 localhost 域,因此您还必须在 httpd-vhosts.conf
文件中定义 locahost。所以你的 httpd-vhosts.conf
文件应该是这样的:
<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>
不要忘记修改 C:\windows\system32\drivers\etc\hosts
文件以像这样添加您的新域
127.0.0.1 localhost
::1 localhost
127.0.0.1 myapp.local
::1 myapp.local
我已经在 wamp 中为新应用程序创建了一个虚拟主机。
在我的httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf //<--- Removed #
在我的 httpd.vhosts.conf
我添加了一个新主机
<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>
虚拟主机工作正常。但问题是我的其他 运行 没有虚拟主机的应用程序无法运行。
当我打开 http://localhost/fistapp/
时显示
Forbidden 403
You don't have permission to access / on this server.
创建虚拟主机定义后,Apache 基本上会忽略 httpd.conf
文件中定义的 localhost 域,因此您还必须在 httpd-vhosts.conf
文件中定义 locahost。所以你的 httpd-vhosts.conf
文件应该是这样的:
<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>
不要忘记修改 C:\windows\system32\drivers\etc\hosts
文件以像这样添加您的新域
127.0.0.1 localhost
::1 localhost
127.0.0.1 myapp.local
::1 myapp.local