以安培为单位设置虚拟主机

时间:2015-07-13 10:31:26

标签: ampps

我试图在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时,我得到了默认的虚拟服务器,我做错了什么?

3 个答案:

答案 0 :(得分:1)

将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>

答案 1 :(得分:1)

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

http://localhost/ampps/

添加域: enter image description here 并做到 enter image description here

答案 2 :(得分: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>