WAMP經常使用環境配置

自定義網站目錄

修改目錄位置

以下圖,打開httpd.conf文件。
這裏寫圖片描述php

查找DocumentRoot(兩處),作以下修改:css

#demo爲自定義網站目錄,下面再也不說明 DocumentRoot "f:/demo" <Directory "F:/demo">

重啓配置服務。web

測試:打開瀏覽器,輸入localhost/test.php(test.php爲demo目錄下新建的測試文件)shell

修改界面顯示

修改wamp安裝目錄下的wampmanager.ini文件:apache

[Menu.Left] ...... Type: item; Caption: "www 目錄"; Action: shellexecute; FileName: "F:/wamp/www"; Glyph: 2 替換爲: Type: item; Caption: "demo 目錄"; Action: shellexecute; FileName: "F:/demo"; Glyph: 2 ......

再修改wamp安裝目錄下的wampmanager.tpl文件:瀏覽器

[Menu.Left] ...... Type: item; Caption: "${w_wwwDirectory}"; Action: shellexecute; FileName: "${wwwDir}"; Glyph: 2 替換爲: Type: item; Caption: "${demo 目錄}"; Action: shellexecute; FileName: "${F:/demo}"; Glyph: 2 ......

重啓配置服務。測試

多站點配置

打開wamp安裝目錄下的bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf文件。(虛擬目錄配置文件)網站

添加以下代碼:spa

//添加站點,test01和test02目錄下放置網站文件 <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com //郵箱地址,可不寫 DocumentRoot "f:/demo/test01" //網站文件目錄 ServerName test01.com //主機名 ErrorLog "logs/dummy-host2.example.com-error.log" //錯誤日誌,可不寫 CustomLog "logs/dummy-host2.example.com-access.log" common //平常日誌,可不寫 </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com //郵箱地址,可不寫 DocumentRoot "f:/demo/test02" //網站文件目錄 ServerName test02.com //主機名 ErrorLog "logs/dummy-host2.example.com-error.log" //錯誤日誌,可不寫 CustomLog "logs/dummy-host2.example.com-access.log" common //平常日誌,可不寫 </VirtualHost>

如上文,再次打開httpd.conf文件,作以下修改:日誌

# Virtual hosts #Include conf/extra/httpd-vhosts.conf 替換爲 # Virtual hosts Include conf/extra/httpd-vhosts.conf
//有些版本沒有,則不用修改 Deny from all Allow from 127.0.0.1 替換爲: Allow from all #Allow from 127.0.0.1

重啓服務

打開C:\Windows\System32\drivers\etc\hosts,添加:

//添加站點
127.0.0.1 test01.com 127.0.0.1 test02.com

測試:打開瀏覽器,輸入test01.com和test02.com。(須要事先在這兩個目錄下寫好測試文件)

自定義端口號

apache默認爲80端口,如被佔用,則須要修改端口號。

如上文,打開httpd.conf文件,作以下修改:

Listen 80 替換爲: Listen 8080(或改爲其它未被佔用端口號)
ServerName localhost:80 替換爲: ServerName localhost:8080(與上面修改的端口號要一致)

重啓服務。

測試:localhost:8080/test.php(前面建的測試文件,在demo目錄下)。

相關文章
相關標籤/搜索