開發過php項目的都知道,大多數都會用到wampserver,接下來小編為大家分享下wampserver改變默認網站目錄的方法。
需要修改的文件有以下三個:
apache2的配置文件 httpd.conf 和 wampserver的 配置文件wampmanager.ini和wampmanager.tpl
其中httpd.conf 可以找到安裝目錄:下 bin\apache\apache2.x.xx\conf\httpd.conf 或者直接在wamp軟件里面點擊
打開配置文件后更改兩處修改成指定的那個目錄就可以了
這樣配置文件中的目錄已經更改了 但是這樣還不行因為wampserver是集成安裝所以在wampserver的配置文件中也有配置文件要修改
在wampserver安裝的目錄下找到
wampmanager.ini
wampmanager.tpl
打開找到
wampmanager.ini中:
type: item; caption: "www directory"; action: shellexecute; filename: "f:\www"; glyph: 2wampmanager.tpl中:type: item; caption: "${w_wwwdirectory}"; action: shellexecute; filename: "f:\www"; glyph: 2
其中f:\www 是我指定的我的目錄 你可以自己制定自己的 修改成你自己的就可以了
然后重啟wampserver就ok了
最后還有一點如果用原來的那個index.php會報錯
原因是這個php中的引用的wampserver配置文件文件是相對路徑
所以 如果還要用原來的那么就改成你相應的那個絕對路徑 或者不用這個
下面在借助一個示例給大家文字說明一下
假設如下:
wamp版本:2.1
wamp2.0安裝目錄:c:/
www目錄:c:/wamp/www/
變更目錄:e:/phproot/
一 主要過程:
(1)修改 c:\wamp\bin\apache\apache2.2.17\conf \httpd.conf(實現更改默認網站路徑,即將http://localhost定向到自己的默認目錄:e:/phproot/)
(2)拷貝并修改index.php(使新默認網站路徑中的index.php可以正常顯示,如果不需要index.php可以略過此步)
(3)修改c:\wamp\wampmanager.ini和c:\wamp\wampmanager.tpl(改菜單中的“www 目錄”指向)
二 具體修改方法全過程:
第一步:修改c:\wamp\bin\apache\apache2.2.17\conf \httpd.conf
查找: documentroot "c:/wamp/www/"
修改: documentroot "e:/phproot/"
查找: <directory "c:/wamp/www/">
修改: <directory "e:/phproot/">
第二步:拷貝并修改index.php
(1)拷貝:
將c:/wamp/www/拷貝至e:/phproot
(2)查找:
//chemin jusqu'au fichier de conf de wampserver
$wampconffile = '../wampmanager.conf';
//chemin jusqu'aux fichiers alias
$aliasdir = '../alias/';
(3)修改:
//chemin jusqu'au fichier de conf de wampserver
$wampconffile = 'c:/wamp/wampmanager.conf';
//chemin jusqu'aux fichiers alias
$aliasdir = 'c:/wamp/alias/';
第三步:修改wampmanager.ini和wampmanager.tpl
1 修改c:\wamp\wampmanager.ini:
(1)打開:c:\wamp\wampmanager.ini
(2)查找:type: item; caption: "www 目錄"; action: shellexecute; filename: "c:/wamp/www/"; glyph: 2
(3)修改:type: item; caption: "www 目錄"; action: shellexecute; filename: "e:/phproot/"; glyph: 2
2 修改c:\wamp\wampmanager.tpl:
(1)打開:c:\wamp\wampmanager.tpl
(2)查找:type: item; caption: "${w_wwwdirectory}"; action: shellexecute; filename: "${wwwdir}"; glyph: 2
(3)修改:type: item; caption: "${w_wwwdirectory}"; action: shellexecute; filename: "e:/phproot"; glyph: 2
完成所有步驟,保存文件,至此修改成功。
以上通過圖片介紹加文字說明的方式總結了wampserver改變默認網站目錄的方法,希望大家喜歡。