为作本地测试及同时使用花生壳
网络上搜索并整理了一下配置apache虚拟主机的方法
测试环境 :Windows apache2.2
主要用于个人在本地使用不同的ip或者端口 创建多个虚拟主机
修改httpd.conf文件 Listen 80
Listen 8080
Listen 12345
以上表示使用80、8080和12345端口,当然这些都是自定的
据说以127开头的ip全部指向本地,测试了一下貌似有这么回事 如127.1.2.3 <VirtualHost *:8080>
DocumentRoot "D:\web/html"
ServerName *:8080
</VirtualHost>
<Directory "D:\web/html">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
以上表示当访问http://ip:8080时 调用的根目录路径为 D:\web\html 方法二:
<VirtualHost 127.0.0.2>
DocumentRoot "D:\web/html"
ServerName 127.0.0.2
</VirtualHost>
<Directory "D:\web/html">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory> <VirtualHost 127.0.0.3:8080>
DocumentRoot "D:\web/html"
ServerName 127.0.0.3:8080
</VirtualHost>
<Directory "D:\web/html">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
其实原理大致相同,具体的环境采用合适的配置方法即可