dourui9570 2016-10-25 21:06
浏览 68
已采纳

启用虚拟主机后,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.
  • 写回答

1条回答 默认 最新

  • dongyi1215 2016-10-26 00:36
    关注

    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
    

    展开全部

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部