2

我正在尝试在 windows 8 下的 ammps 中创建一个虚拟主机,文档根目录应该在外部硬盘驱动器 F: 目录下,这是我的 httpd.conf

<VirtualHost 127.0.0.1:80>
    <Directory "{$path}/www">
        Options FollowSymLinks Indexes
        AllowOverride All
        Order deny,allow
        allow from All
    </Directory>
    ServerName localhost
    ServerAlias localhost 127.0.0.1
    ScriptAlias /cgi-bin/ "{$path}/www/cgi-bin/"
    DocumentRoot "{$path}/www"
    ErrorLog "{$path}/apache/logs/error.log"
    CustomLog "{$path}/apache/logs/access.log" combined
</VirtualHost>

<VirtualHost *:80>
    <Directory "F:/www">
        Options FollowSymLinks Indexes
        AllowOverride All
        Order deny,allow
        allow from All
    </Directory>
    DocumentRoot "F:/www"
    ServerName site1.com
</VirtualHost>

这是我的主机文件

127.0.0.1           site1.com
127.0.0.1           site2.com
127.0.0.1           site3.com
127.0.0.1           site4.com
127.0.0.1           site5.com

当我输入 site1.com 时,我得到了默认的虚拟服务器,我做错了什么?

4

3 回答 3

3

将 IP 地址从 * 更改为 127.0.0.1 这应该可以解决它

希望有帮助!

它应该看起来像这样

<VirtualHost 127.0.0.1:80>
<Directory "{$path}/www">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
</Directory>
ServerName localhost
ServerAlias localhost 127.0.0.1
ScriptAlias /cgi-bin/ "{$path}/www/cgi-bin/"
DocumentRoot "{$path}/www"
ErrorLog "{$path}/apache/logs/error.log"
CustomLog "{$path}/apache/logs/access.log" combined
</VirtualHost>

<VirtualHost *:80>
<Directory "F:/www">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
</Directory>
DocumentRoot "F:/www"
ServerName site1.com
</VirtualHost>
于 2015-07-13T10:34:13.947 回答
3

最好通过其管理面板在 AMPPS 中创建虚拟主机

http://localhost/ampps/

添加域: 在此处输入图像描述 然后就做 在此处输入图像描述

于 2018-12-27T10:09:56.653 回答
0

1 登录 http://localhost/ampps/ 2 添加域 3 添加到文件 Ampps\conf\httpd.conf 行 #530

    <VirtualHost ssd.co>
<Directory "H:/WWW/ssd.co/">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
</Directory>
ServerName localhost
ServerAlias localhost ssd.co
ScriptAlias /cgi-bin/ "{$path}/www/cgi-bin/"
DocumentRoot "H:/WWW/ssd.co/"
ErrorLog "{$path}/apache/logs/error.log"
CustomLog "{$path}/apache/logs/access.log" combined
</VirtualHost>
于 2021-08-04T11:27:12.117 回答