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