WAMPSERVER多站點配置

1.配置wamp網站地址:

找到wamp的安裝目錄,如~\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.confphp

打開httpd-vhosts.conf文件html

其中有默認的樣例:web

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>apache

咱們配置本身的網站時,能夠簡單點:瀏覽器

<VirtualHost *:80>
DocumentRoot "e:demo/test01"  (這裏是要設置站點的路徑)
ServerName test01.com   (這裏是要設置站點的域名)
</VirtualHost>ide

設置好後保存,有任何改動了配置的操做都要從新啓動wamp測試

2.配置Apache:

打開httpd.conf文件,可參考:http://www.cnblogs.com/junglexj/p/6016755.html網站

將其中spa

# Virtual hosts
#Include conf/extra/httpd-vhosts.confhtm

第二行「#」去掉,表示容許;

再找到以前<Directory "e:/demo">裏,設置成

# onlineoffline tag - don't remove
Order Deny,Allow
Allow from all
#Allow from 127.0.0.1

3.配置hosts文件

目錄:C:\Windows\System32\drivers\etc\hosts

在最下面添加一行  

127.0.0.1       test01.com

保存退出,若沒法保存請copy一份hosts文件到桌面編輯,再替換到C:\Windows\System32\drivers\etc目錄下便可。

 

能夠在新建一個php文件測試,e:/demo/test01/index.php

其中index.php的內容爲:

<?php
echo "hello world";
?>

保存,在瀏覽器訪問http://test01.com/test01/即可顯示 "hello world" ;

注意,如果修改過默認端口,訪問時要在域名後面加端口號,好比:http://test01.com:8080/test01/

 

參考:http://www.imooc.com/video/3521

相關文章
相關標籤/搜索