服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - PHP教程 - wampserver改变默认网站目录的办法

wampserver改变默认网站目录的办法

2020-11-15 21:47PHP教程网 PHP教程

大家在做php项目时,很多项目都会用到wampserver。WampServe集成了Apache、MySQL、PHP、phpmyadmin,支持Apache的mod_rewrite,PHP扩展、Apache模块只需要在菜单“开启/关闭”上点点就搞定,省去了修改配置文件的麻烦,这里就简写成wamp。

开发过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是集成安装所以在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了

wampserver改变默认网站目录的办法

最后还有一点如果用原来的那个index.php会报错

wampserver改变默认网站目录的办法

原因是这个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改变默认网站目录的方法,希望大家喜欢。

延伸 · 阅读

精彩推荐