【发布时间】:2012-02-09 11:15:07
【问题描述】:
如何将我的默认 xampp localhost c:xampp/htdoc 更改为另一个文件夹,即 c:/alan?当我使用 IP 地址时,我应该能够在C:/alan 中查看我的网站文件。
感谢您帮助我。
【问题讨论】:
如何将我的默认 xampp localhost c:xampp/htdoc 更改为另一个文件夹,即 c:/alan?当我使用 IP 地址时,我应该能够在C:/alan 中查看我的网站文件。
感谢您帮助我。
【问题讨论】:
编辑 httpd.conf 文件并将 DocumentRoot "/home/user/www" 行替换为您喜欢的行。
默认的DocumentRoot路径对于windows会有所不同[以上是针对linux的]。
【讨论】:
请听从@Sourav 的建议。
如果重启服务器后出现错误,您可能还需要设置目录选项。这是在 httpd.conf 中的 <Directory> 标记中完成的。确保最终配置如下所示:
DocumentRoot "C:\alan"
<Directory "C:\alan">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
【讨论】:
<Directory> 部分应该在它之后的某个地方,但由于我使用不同的服务器和不同的平台,我真的没有办法确定。
步骤:
替换
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
这两行
| C:/xampp/htdocs == root 的当前位置 |
|用你想要的任何位置更改 C:/xampp/htdocs|
完成: 启动 apache 并转到 localhost 查看实际操作 [watch video click here]
【讨论】:
使用Xampp 1.8.3-5 Ubuntu 14.04 可以分两步完成
第 1 步:- 更改 /opt/lampp/etc/httpd.conf 中的 DocumentRoot 和 Directory 路径
来自
DocumentRoot "/opt/lampp/htdocs" 和 Directory "/opt/lampp/htdocs"
到
DocumentRoot "/home/user/Desktop/js" 和 Directory "/home/user/Desktop/js"
第 2 步:- 更改文件夹的权限(在路径及其其父文件夹为 777) 例如通过
sudo chmod -R 777 /home/user/Desktop/js
【讨论】:
以防万一有人查找此文件,Linux 中 Sourav 答案 (httpd.conf) 上文件的路径是 /opt/lampp/etc/httpd.conf
【讨论】:
在 Linux Mint(基于 Debian)上转到 /opt/lampp/etc/httpd.conf
找到 YOUR_OWN_FILES_LOCATION 当然是您的文件位置。
DocumentRoot "YOUR_OWN_FILES_LOCATION"
<Directory "YOUR_OWN_FILES_LOCATION">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride None
# since XAMPP 1.4:
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
【讨论】:
对我来说,它位于第 183 行,但它仅在您重新启动计算机后才有效。我希望有一种方法可以快速更改它而无需每次都重新启动,但目前我知道这是唯一的方法。
【讨论】:
@Hooman:实际上使用最新版本的 Xampp,您不需要知道配置或日志文件在哪里;在控制面板中,您有每个工具(php、mysql、tomcat...)的日志和配置按钮,单击它们可以打开所有相关文件(您甚至可以使用顶部的常规配置按钮更改默认编辑应用程序正确的)。为设计它的人干得好!
【讨论】:
我必须同时更改 httpd.conf 和 httpd-ssl.conf 文件的 DocumentRoot 属性,以使相关链接(即 href="/index.html")和 favicon.ico 链接等内容正常工作。
最新的 Xampp 控制面板使这变得非常简单。
从控制面板中,第一行应该有 Apache。如果它开始了,请停止它。然后点击 config 并打开 httpd.conf 文件并搜索 htdocs 或 documentRoot。将路径更改为您喜欢的路径。对 httpd-ssl.conf 执行相同的操作。这些应该是 Config 下拉列表中的前 2 个文件。
然后重新启动服务器。
希望这对某人有所帮助。干杯。
【讨论】: