403更改DocumentRoot目录后禁止Apache 2.4.6
所以我刚安装了一个带Ubuntu 13.10的虚拟机。 在更新我的ubuntu 12.04服务器之前,我想使用apache 2.4.6。 我希望我的文档根目录在我的主文件夹中,所以我在etc/apache2/sites-available/000-default.conf
更改了它
当我这样做时,我只是得到禁止的消息。 我将新文件夹权限设置为777但仍然被禁止。 我甚至将一个index.html文件放在新目录中,它只是说出了hello world,但仍然没有。 这是我的000-default.conf文件。
# The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /home/everett/webroot Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, eg #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
我有完全相同的问题,我解决了这个问题:
第一; 我按照Ubuntu服务器指南页面上的说明执行了这些步骤
- 转到终端并将默认虚拟主机配置复制到新配置(
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mynewsite.conf
) - 编辑这个新文件(
sudo gedit /etc/apache2/sites-available/mynewsite.conf
)并将DocumentRoot更改为您自己的文件 (保存并关闭..) - 启用此新配置文件(
sudo a2ensite mynewsite.conf
)并禁用默认配置文件(sudo a2dissite 000-default.conf
) - 编辑apache2.conf(
sudo gedit /etc/apache2/apache2.conf
)并将default
更改为:Options Indexes FollowSymLinks AllowOverride None Require all granted
(保存并关闭.. )Options Indexes FollowSymLinks AllowOverride None Require all granted - 重启Apache2(
sudo service apache2 restart
)
如果已经有效:太棒了!
如果没有,那么您应该检查每个基于命名的
需要一个不同的ServerName
集,包括000-default.conf
如果存在)。 您可以在终端中运行apachectl -S
以查看所有内容的快速列表。
如果它仍然不起作用,那么你应该检查你的目录(以及通向它的完整路径!)是否具有正确的读取和执行权限 (rx)。
- 转到你的root(
cd /
)并执行ls -l
,你可以看到像drwxr-xr-x 14 root root 4096 mei 1 01:24 [your_directory]
。 - 导致www文件夹的所有目录都应该有“drwxr-xr-x” – 权限,如果没有,你可以使用
sudo chmod -R a+rx [your_directory]
更改它
如果你仍然无法让它工作,你应该检查apache error-log( sudo gedit /var/log/apache2/error.log
)并进一步挖掘……
祝好运!
亲爱的,我想通知您,您正在更改默认的apache配置。
从000-default.conf文件中删除这些行。
选项FollowSymLinks MultiViews
AllowOverride All
订单允许,拒绝
要求全部授予
目录>
打开你的apache.conf文件(/etc/apache2/apache.conf)并查找目录或转到第no行。 172.你在哪里找到“目录/ var / www /”在这里定义你的目录“/ home / everett / webroot”保存并重新启动你的apache并刷新你的网页。