首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wampserver VirtualHost

wampserver VirtualHost
EN

Server Fault用户
提问于 2012-08-20 12:41:38
回答 3查看 1.4K关注 0票数 -1

我在设置新项目上有问题。我刚安装了wamp 2.2E。我正在使用windows。在文件夹/www中,我创建了文件夹/example。在WINDOWS/system32 32/驱动程序/etc/主机中,我添加了

代码语言:javascript
复制
127.0.0.1       dev.example.com

在G:\wamp\bin\apache\apache2.2.22\conf\extra\httpd-vhosts.conf中,在末尾添加

代码语言:javascript
复制
NameVirtualHost dev.example.com:80
<VirtualHost dev.example.com:80>
   DocumentRoot "G:/wamp/www/example"
   ServerName dev.example.com
   ServerAlias dev.example.com

   <Directory "G:/wamp/www/example">
      Options Indexes FollowSymLinks ExecCGI Includes
      AllowOverride All
      Order allow,deny
      Allow from All
   </Directory>
</VirtualHost>

问题是当我转到dev.example.com/index.php时,我仍然从www/index.php获得内容,而不是www/example.com/index.php。我错过什么了吗?

EN

回答 3

Server Fault用户

回答已采纳

发布于 2012-08-20 12:44:31

可能是在更改之后您没有重新启动apache服务器吗?

这里有一个我自己的vhost:

首先,您需要在httpd-vhosts.conf文件的开头添加:

代码语言:javascript
复制
NameVirtualHost *:80 

然后,vhost定义本身:

代码语言:javascript
复制
<VirtualHost *:80>
DocumentRoot "C:/WEB/DOCUMENT_ROOT/www_foxmask/www/"
ServerName foxmask.localhost

<Directory "C:/WEB/DOCUMENT_ROOT/www_foxmask/www/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Directory>

CustomLog "C:\WEB\DOCUMENT_ROOT\apache_logs\www_foxmask.log" common
ErrorLog  "C:\WEB\DOCUMENT_ROOT\apache_logs\www_foxmask-error.log"
</VirtualHost>

nota :在您的httpd.conf中,您应该使用这一行使httpd-vhosts.conf正确工作:

代码语言:javascript
复制
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

文件的路径取决于您的安装。

希望这能帮上忙

票数 1
EN

Server Fault用户

发布于 2012-08-20 12:51:24

试试VirtualHost *:80

据我所知,DNS的名称是由ServerAlias使用的。

如果您有一个仅以ServerAlias作为通配符的*,则在*条目之前设置dev.example.com

票数 0
EN

Server Fault用户

发布于 2012-08-20 15:44:28

问题是我错过了一步。在文件中: G:\wamp\bin\apache\Apache2.2.22\conf\httpd.conf查找:#包含conf/extra/httpd-vhosts.conf并删除#

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/419909

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档