setting up virtual hosts in ampps

妖精的绣舞 提交于 2020-01-15 06:37:08

问题


I am trying to create a virtual host in ammps under windows 8, the document root should be under an external hard drive F: directory this is my 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>

and this is my hosts file

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

when I type site1.com , I get the default virtual server instead, what I am doing wrong ?


回答1:


change the ip address from * to 127.0.0.1 this should fix it

hope that helps !

it should look like this

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



回答2:


its better to create Virtual host in AMPPS via its admin panel

http://localhost/ampps/

add domain: and justdo it



来源:https://stackoverflow.com/questions/31380981/setting-up-virtual-hosts-in-ampps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!