WAMP中的Web服务器根目录在哪里?
Web 服务器根目录也是您放置站点文件并稍后在浏览器中使用 localhost/file_name 访问它们的位置吗?
Also is the web server root directory the place where you put your site files and later acces them with localhost/file_name in the browser?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您将 WAMP 安装到
c:\wamp
,那么我相信您的网络服务器根目录将为c:\wamp\www
,但这可能会因版本而异。是的,您可以将站点文件放置在此处,以便通过浏览器访问它们。
If you installed WAMP to
c:\wamp
then I believe your webserver root directory would bec:\wamp\www
, however this might vary depending on version.Yes, this is where you would put your site files to access them through a browser.
在 WAMP 中,文件由 Apache 组件(WAMP 中的 A)提供服务。
在 Apache 中,默认情况下提供的文件位于安装目录的子目录
htdocs
中。但这是可以改变的,实际上是在WAMP安装Apache时改变的。提供文件的位置称为
DocumentRoot
,并使用 Apache 配置文件中的变量进行定义。默认值是相对于ServerRoot
目录的子目录htdocs
。默认情况下,
ServerRoot
是 Apache 的安装目录。然而,这也可以在配置文件中重新定义,或者使用用于启动 Apache 的命令httpd
的-d
选项。配置文件中的值会覆盖-d
选项。默认情况下,配置文件是相对于
ServerRoot
的conf/httpd.conf
。但可以使用命令 httpd 的-f
选项来更改此设置。当 WAMP 安装自身时,它会使用
DocumentRoot c:/wamp/www/
修改默认配置文件。 要提供的文件需要位于此处,而不是位于htdocs
默认目录中。您可以通过修改默认配置文件中的
DocumentRoot
或使用两个命令行选项-f
或- 之一来更改 WAMP 设置的此位置。 d
显式或隐式指向一个新的配置文件,该文件可能为DocumentRoot
保存不同的值(在这种情况下,新文件需要包含此定义,但也包含配置的其余部分)在默认配置文件中找到)。In WAMP the files are served by the Apache component (the A in WAMP).
In Apache, by default the files served are located in the subdirectory
htdocs
of the installation directory. But this can be changed, and is actually changed when WAMP installs Apache.The location from where the files are served is named the
DocumentRoot
, and is defined using a variable in Apache configuration file. The default value is the subdirectoryhtdocs
relative to what is named theServerRoot
directory.By default the
ServerRoot
is the installation directory of Apache. However this can also be redefined into the configuration file, or using the-d
option of the commandhttpd
which is used to launch Apache. The value in the configuration file overrides the-d
option.The configuration file is by default
conf/httpd.conf
relative toServerRoot
. But this can be changed using the-f
option of command httpd.When WAMP installs itself, it modify the default configuration file with
DocumentRoot c:/wamp/www/
. The files to be served need to be located here and not in thehtdocs
default directory.You may change this location set by WAMP, either by modifying
DocumentRoot
in the default configuration file, or by using one of the two command line options-f
or-d
which point explicitly or implicity to a new configuration file which may hold a different value forDocumentRoot
(in that case the new file needs to contain this definition, but also the rest of the configuration found in the default configuration file).用户“mins”建议的所有内容都是正确的,并且是极好的信息。
当您在浏览器中输入 localhost 时,WAMP 2.5 提供默认的服务器配置显示。这映射到 c:\wamp\www,如之前的帖子中所述。在 www 下创建子目录将导致项目出现在此显示屏上。单击一下,您就进入了您的项目。
我在不同的目录结构下有各种项目,有时在共享驱动器上,这使得文件的集中位置不方便。幸运的是,WAMP 2.5 还有第二个功能,即 Alias,它使得指定一个(或多个)不同 Web 目录的位置变得非常容易。无需编辑配置文件。使用 WAMP 菜单,选择 Apache >别名目录>添加别名。
WAMP 已经得到很好的发展,可以为各种开发人员偏好提供支持。
Everything suggested by user "mins" is correct, and excellent information.
WAMP 2.5 provides a default Server Configuration display when you enter localhost into your browser. This maps to c:\wamp\www, as described in previous posts. Creating subdirectories under www will cause Projects to appear on this display. A click and you're in your project.
I have various projects under different directory structures, sometimes on shared drives which makes this centralized location of files inconvenient. Luckily, there is a second feature of WAMP 2.5, an Alias, which makes specifying the location of one (or more) disparate web directories quite easy. No editing of configuration files. Using the WAMP menu, choose Apache > Alias directories > Add an Alias.
WAMP has evolved nicely to provide support for a variety of developer preferences.
如果您使用 wampstack 的 Bitnami 安装程序,请转到:
c:/Bitnami/wampstack-5.6.24-0/apache/conf(当然您的版本号可能不同)
打开文件:
httpd.conf 在 Visual Studio code 或 Notepad ++ 等文本编辑器中
搜索“DocumentRoot”。参见图片。
您将能够更改此文件中的目录。
If you use Bitnami installer for wampstack, go to:
c:/Bitnami/wampstack-5.6.24-0/apache/conf (of course your version number may be different)
Open the file:
httpd.conf in a text editor like Visual Studio code or Notepad ++
Do a search for "DocumentRoot". See image.
You will be able to change the directory in this file.
要检查你的根目录是什么,请转到 apache 的 httpd.conf 文件并搜索“DocumentRoot”。它后面的位置就是你的根目录
To check what is your root directory go to httpd.conf file of apache and search for "DocumentRoot".The location following it is your root directory
这是 Web 根目录 c:\wamp\www 的路径,
您可以通过向此目录添加不同的文件夹来创建不同的项目,并像这样调用它们:
从浏览器中调用 localhost/project1
这将运行 index.html 或 index.php,说谎项目内部1
this is the path to the web root directory c:\wamp\www
you can create different projects by adding different folders to this directory and call them like:
localhost/project1 from browser
this will run the index.html or index.php, lying inside project1
以下是我在 Windows 上使用版本 3.0.6 实现此目标的方法
Here's how I get there using Version 3.0.6 on Windows