更改Apache2文档根 [英] Change Apache2 Document Root

查看:269
本文介绍了更改Apache2文档根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache2在Ubuntu 14.04上,全新安装。

Apache2 on Ubuntu 14.04, fresh installation.

想要从默认 / var / www / html / home / me / mywebroot

更改了文件 / etc / apache2 /apache2.conf 以及 /etc/apache2/sites-availabe/000-default.conf /etc/apache2/sites-enabled/000-default.conf 每次发生 / var / www / html / home / me / mywebroot

Changed in files /etc/apache2/apache2.conf as well as in /etc/apache2/sites-availabe/000-default.conf and in /etc/apache2/sites-enabled/000-default.conf every occurence of /var/www/html to /home/me/mywebroot.

现在,我 /etc/init.d/apache2 restart

仍然,当我在浏览器中输入 http:// localhost 时,我得到的默认页面位于 / var / www / html - 即使在任何配置文件中没有出现此文件夹。

Still, when I enter http://localhost in the browser, I get the default page located in /var/www/html -even though there is no occurence of this folder in any of the config documents.

我可以做什么?

推荐答案

不应该是VirtualHost,而不是在apache2.conf中的DocumentRoot定义 - 你是否可以更改apache2.conf中的以下内容?

first of all, there should not be VirtualHost and not DocumentRoot definition in apache2.conf - did you maybe change the following in apache2.conf?

<Directory /var/www/>
    Options FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

如果是这样,则反转此更改!

if so, then reverse this change!

第二,所有在网站启用的文件应该是符号链接到网站中的文件可用。所以如果你第一次更改了一个,仍然不得不改变另一个,我建议删除和清除apache2(确保/ etc / apache2 /后是空),然后重新安装apache2。

second of all, all files in sites-enabled should be symlinks to files in sites-available. so if you first changed one of both and still had to change the other, I would recommend to remove and purge apache2 (make sure /etc/apache2/ is empty after that) and reinstall apache2.

所有你应该做的是将/ etc / apache2 / sites-enabled / 000-default中的DocumentRoot更改为/ home / me / mywebroot,并确保添加DirectoryIndex指令以反映任何Document .html)。

All you should have to do is change DocumentRoot in /etc/apache2/sites-enabled/000-default to /home/me/mywebroot and make sure you add a DirectoryIndex directive to reflect whatever Document (eg index.html) you want to serve.

这篇关于更改Apache2文档根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆