php 如何更改 WampServer 2.5 上的 www 根目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31635648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:33:13  来源:igfitidea点击:

How to Change the www root directory on WampServer 2.5

phpwampwampserver

提问by c0der

My need is to change the default sites directory of wamp from say "c:\wamp\www" to say "d:\sites". Right now my projects in "d:\sites" do not show in the project list:

我需要将 wamp 的默认站点目录从“c:\wamp\www”更改为“d:\sites”。现在我在“d:\sites”中的项目没有显示在项目列表中:

enter image description here

在此处输入图片说明

I found a few past answers like this oneand thisone which I think are not applicable to WampServer 2.5 (anyway, it did not work for me).

我发现了一些过去的答案是这样一个一个我认为并不适用于WampServer 2.5(无论如何,它并没有为我工作)。

I also found this procedurein the documentation, but it seems far too complex for what I need.

我还在文档中找到了这个过程,但它似乎太复杂了,无法满足我的需要。

Any help on this matter would be appreciated.

对此事的任何帮助将不胜感激。

回答by psycho brm

In newer version of wamp, changing DocumentRoot in httpd.conf did not change DOCUMENT_ROOT. Even after restarting, it stayed as "c:/wamp64/www/".

在较新版本的 wamp 中,更改 httpd.conf 中的 DocumentRoot 不会更改 DOCUMENT_ROOT。即使重新启动后,它仍为“c:/wamp64/www/”。

Instead, the DocumentRoot is set in this file:

相反, DocumentRoot 在此文件中设置:

  c:\wamp64\bin\apache\apache2.4.18\conf\extra\httpd-vhosts.conf
  c:\wamp64\bin\apache\apache2.4.18\conf\extra\httpd-vhosts.conf

To change the localhost directory, change these to your path:

要更改 localhost 目录,请将这些更改为您的路径:

      DocumentRoot c:/www
      <Directory  "c:/www/">
      DocumentRoot c:/www
      <Directory  "c:/www/">

回答by g1ji

The thing you wanna do is little bit tricky.To do the thing you want just follow following steps:

你想做的事情有点棘手。要做你想做的事情,只需按照以下步骤:

1Open file C:\wamp\bin\apache\Apache*.*.*\conf\httpd.conf

1打开文件C:\wamp\bin\apache\Apache*.*.*\conf\httpd.conf

2Find following lines :

2找到以下几行:

DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">

3Modify them to change your root directory /*In my case i want my "C:\" drive as root*/so i do this :

3修改它们以更改您的根目录, /*In my case i want my "C:\" drive as root*/所以我这样做:

DocumentRoot "c:/"
<Directory "c:/">

4Now go to c:\wamp\wwwfind index.phpand copy it,and pest into your new root /*In my case i want my "C:\" drive as root*/

4现在去c:\wamp\www查找index.php并复制它,然后将其放入新的根目录中/*In my case i want my "C:\" drive as root*/

5Now open that index.phpand find the following lines:

5现在打开它index.php并找到以下几行:

$wampConfFile = '../wampmanager.conf';
$aliasDir = '../alias/';

6Now just modify them relative to your root /*In my case i want my "C:\" drive as root*/so i write:

6现在只需相对于您的根修改它们,/*In my case i want my "C:\" drive as root*/所以我写:

$wampConfFile = './wamp/wampmanager.conf';
$aliasDir = './wamp/alias/';

Now it will show the default wamp opening page which is shown in the picture!

现在它将显示如图所示的默认 wamp 打开页面!

回答by Pablo Salazar

  1. Search the httpd.conffile
  1. 搜索httpd.conf文件

enter image description here

在此处输入图片说明

  1. Change the DocumentRootand Path with the one that you want:
  1. 更改DocumentRoot与您想要的路径:

enter image description here

在此处输入图片说明

  1. Search the httpd-vhosts.conffile
  1. 搜索httpd-vhosts.conf文件

enter image description here

在此处输入图片说明

  1. Change the DocumentRootand Path with the one that you want:
  1. 更改DocumentRoot与您想要的路径:

enter image description here

在此处输入图片说明

  1. Restart All services
  1. 重启所有服务

enter image description here

在此处输入图片说明

回答by Pranav V R

  1. Go to apache httpd

    C:\wamp\bin\apache\apache2.2.22\conf

  2. Open httpd

  3. Find DocumentRootin that file

  4. Change the path

  5. Find the directory tag

  6. Change to Allow from allfrom Deny from allin Directory tag

    <Directory />
      Options FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
    
  7. Save & exit

  8. Restart wamp services

  1. 转到 apache httpd

    C:\wamp\bin\apache\apache2.2.22\conf

  2. 打开httpd

  3. 在该文件中查找DocumentRoot

  4. 改变路径

  5. 找到目录标签

  6. 更改为所有允许所有拒绝在目录标签

    <Directory />
      Options FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
    
  7. 保存并退出

  8. 重启 wamp 服务

回答by ajs

Edit the path in below file then restart wamp server C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf

编辑以下文件中的路径,然后重新启动 wamp 服务器 C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf