修改apache网站根目录无效(笔记)
- 本人是修改apache网站根目录是改
http.conf
文件与httpd-vhosts.conf
文件 - 其中
http.conf
在apache根目录下的conf
文件夹下,httpd-vhosts.conf
在apache根目录下的conf\extra
文件夹下 - 修改完成后重启apache,如果修改结果无效则需要重启电脑!(本人第一次把默认文档
htdocs
修改为E:/StudyFile/phpAndApache/WWW
是成功的,但是第二次修改为F:/code
却发现修改无效,apache访问的还是第一次修改的路径,百度好几个方法都没成功!最后重启电脑后成功了!这个处理方法不一定适用所有情形!)
修改内容
http.conf
文件中的DocumentRoot "F:/code"
与
<Directory "F:/code">
两处改为自己的存放目录
# documents. By default, all requests are taken from this directory, but
#symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "${SRVROOT}/htdocs"
#修改apache网站根目录
#DocumentRoot "E:/StudyFile/phpAndApache/WWW"
#DocumentRoot "E:/StudyFile/phpAndApache/WWW"
#<Directory "E:/StudyFile/phpAndApache/WWW">
DocumentRoot "F:/code"
<Directory "F:/code">
#
# 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"
httpd-vhosts.conf
文件(有修改过虚拟主机的则需要配,没有则无需修改)
这里我是有配置虚拟主机的,把虚拟主机的DocumentRoot文件根目录改为与http.conf
文件相同的根目录
<VirtualHost *:80>
# serverAdmin 为站长邮箱
# ServerAdmin webmaster@dummy-host2.example.com
# 网站根目录
# DocumentRoot "E:/StudyFile/phpAndApache/WWW"
DocumentRoot "F:/code"
ServerName hhh917.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
修改完成后保存文件,重启apache服务!apache网站根目录修改完成!