wamp建立虚拟目录/虚拟站点

方法一、
第一步:
打开“Apache2\conf\extra”下的“httpd-vhosts.conf”文件
“#”号注视部分可以删掉,一下为虚拟目录配置,假设有两个网站:wordpress和wordpress2,配置如下。

01 NameVirtualHost *:80
02 <VirtualHost *:80>
03     <Directory "E:/wamp/www/wordpress">
04         Options -Indexes FollowSymLinks
05         Allow from all
06         AllowOverride All
07     DirectoryIndex  index.php
08     </Directory>
09     ServerAdmin [email protected]
10     DocumentRoot "E:/wamp/www/wordpress"
11     ServerName wordpress.com
12     ServerAlias www.wordpress.com
13     ErrorLog "logs/dummy-host.localhost-error.log"
14     CustomLog "logs/dummy-host.localhost-access.log" common
15 </VirtualHost>
16  
17 <VirtualHost *:80>
18     <Directory "E:/wamp/www/wordpress2">
19         Options -Indexes FollowSymLinks
20         Allow from all
21         AllowOverride All
22     DirectoryIndex  index.php
23     </Directory>
24     ServerAdmin [email protected]
25     DocumentRoot "E:/wamp/www/wordpress2"
26     ServerName wordpress2.com
27     ServerAlias www.wordpress2.com
28     ErrorLog "logs/dummy-host.localhost-error.log"
29     CustomLog "logs/dummy-host.localhost-access.log" common
30 </VirtualHost>

第二部:
打开"Apache2\conf"下的"httpd.conf"文件
找到
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
改成
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

保存重启wamp

第三部:
测试
可以更改本地“host”文件进行测试
打开“C:\WINDOWS\system32\drivers\etc”下“hosts”文件
添加
127.0.0.1       www.wordpress.com
127.0.0.1       www.wordpress2.com

保存之后就可以在浏览器中输入这两个域名测试了,这时候访问的就是本地电脑上的网站

方法二、
直接可以直接修改httpd.conf文件,省去了方法一的第二部。

注意:以上方法不只局限于wamp,lamp也同样适用。

猜你喜欢

转载自hcty31.iteye.com/blog/2179414