简体   繁体   English

启用虚拟主机后Wamp目录不起作用

[英]Wamp directories not working after enabling virtual host

I have created a virtual host for a new application in wamp. 我为wamp中的新应用程序创建了虚拟主机。

In my httpd.conf 在我的httpd.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf  //<--- Removed #

In my httpd.vhosts.conf I added a new host 在我的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>

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 当我打开http://localhost/fistapp/它显示

Forbidden 403

You don't have permission to access / on this server.

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. 创建虚拟主机定义后,Apache基本上会忽略httpd.conf文件中定义的localhost域,因此,您还必须在httpd-vhosts.conf文件中定义locahost。 So your httpd-vhosts.conf file should look like this : 因此,您的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>

Dont forget to amend the C:\\windows\\system32\\drivers\\etc\\hosts file to add your new domain like this 不要忘记修改C:\\windows\\system32\\drivers\\etc\\hosts文件以添加您的新域

127.0.0.1  localhost
::1 localhost

127.0.0.1 myapp.local
::1 myapp.local

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM