如何将默认的examplep 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>
步骤:
- 运行xampp控制面板
- 点击"配置"按钮
- 选择apache(httpd.conf)
- 查找文档根
更换
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
那两条线
|C:\xamplep/htdocs==根|的当前位置
|将C:/examplep/htdocs更改为您想要的任何位置|
- 保存它
完成:启动apache并转到localhost查看实际操作[观看视频单击此处]
对于带有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 answer(httpd.conf)上的文件路径为/opt/lamp/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下拉列表中的前两个文件。
然后重新启动服务器。
希望这能帮助到别人。干杯