升级到 Ubuntu 13.10 后,laravel 项目在 Apache 上出现 403 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19481660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
403 error on Apache for a laravel project, after upgrade to Ubuntu 13.10
提问by Brennan Hoeting
I upgraded to Ubuntu 13.10. At first when running apache after the update, there were missing/broken files, so I simply re-installed apache. I backed up the vhost file.
我升级到 Ubuntu 13.10。起初在更新后运行apache时,文件丢失/损坏,所以我只是重新安装了apache。我备份了 vhost 文件。
When trying to access my Laravel project from the browser, it get a 403 error. I have changed the permissions of the root folder multiple times, but it is still forbidden. I do not believe this is a laravel problem, as I already fixed it on 13.04, and I am using the same files.
尝试从浏览器访问我的 Laravel 项目时,出现 403 错误。我已经多次更改根文件夹的权限,但仍然被禁止。我不相信这是 Laravel 问题,因为我已经在 13.04 上修复了它,并且我正在使用相同的文件。
Here is my 000-default.conf file, located in /sites-enabled and /sites-available. My apache2.conf file is unchanged since install.
这是我的 000-default.conf 文件,位于 /sites-enabled 和 /sites-available。我的 apache2.conf 文件自安装以来没有改变。
<VirtualHost *:80>
DocumentRoot /home/brennan/development/MasonACM/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/brennan/development/MasonACM/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
It should also be important to note that my .htaccess file is not missing, and hasn't been changed since the site was working on 13.04.
同样重要的是要注意我的 .htaccess 文件没有丢失,并且自该站点在 13.04 上工作以来没有更改。
UPDATE:
更新:
I have apache's host settings working now, but now the browser is displaying the actual code of index.php, meaning apache isn't using php for some reason. I just checked that php was installed, so why wouldn't apache recognize it?
我现在可以使用 apache 的主机设置,但是现在浏览器正在显示 index.php 的实际代码,这意味着 apache 由于某种原因没有使用 php。我刚刚检查了 php 是否已安装,为什么 apache 不能识别它?
回答by fideloper
Apache2 may have also been upgraded to version 2.4
, and there are a few things to note.
Apache2 可能也升级到版本了2.4
,有几点需要注意。
First, do you have Apache 2.4.x+ now? Check by running:
首先,你现在有 Apache 2.4.x+ 吗?通过运行检查:
$ apache2 -v
If so, your vhost needs some adjustment:
如果是这样,您的虚拟主机需要进行一些调整:
First: +/- on Options:
第一:+/- 选项:
Some Options
parameters needs the +/- syntax. Read more here. This might be especially important when mixing +/- on some directives (read the previous link to see more).
某些Options
参数需要 +/- 语法。在这里阅读更多。在某些指令上混合 +/- 时,这可能尤其重要(阅读上一个链接以了解更多信息)。
Change:
改变:
Options Indexes FollowSymLinks MultiViews
to:
到:
Options +Indexes +FollowSymLinks +MultiViews
Second: Allow/Deny
第二:允许/拒绝
Apache now does access control via mod_authz_host
Apache 现在通过mod_authz_host 进行访问控制
Change:
改变:
Order allow,deny
Allow from all
to:
到:
Require all granted
Some more info here on upgrading from Apache 2.2 to 2.4.
关于从 Apache 2.2 升级到 2.4 的更多信息。
回答by Staple
I had the same problem, for some reason restarting Apache with Sudo made a difference. Are mods rewrite and mcrypt healthy?
我遇到了同样的问题,出于某种原因,使用 Sudo 重新启动 Apache 会有所不同。mods 重写和 mcrypt 健康吗?
回答by Petar Vasilev
I had a problem where in the routes file (web.php) I had two routes (the same link) but different controller action. The second action was empty that's why it was blank.
我有一个问题,在路由文件 (web.php) 中有两条路由(相同的链接)但控制器操作不同。第二个动作是空的,这就是为什么它是空的。
For example:
例如:
Route::get('/route', 'Controller@firstAction');
Route::get('/route', 'Controller@secondAction');