问题描述
我在Heroku上部署了我的laravel 5.4应用程序。问题是,我收到以下错误消息:
禁止的
您无权访问/在此服务器上
我的Procfile:
$ b
web :vendor / bin / heroku-php-apache2 public /
纵观日志,我发现它已尝试'app /'而不是'/'。
我的日志
2017-12-03T14:18:45.747195 + 00:00 app [web.1]:[Sun Dec 03 14:18:45.746749 2017] [autoindex:错误] [pid 122:tid 140692458305280] [client 10.140.221.43:41026] AH01276:无法提供目录/ app /:找不到匹配的DirectoryIndex(index.php,index.html,index.htm),以及服务器生成的目录索引禁止使用Options指令
我的.htaccess:
< IfModule mod_rewrite.c>
< IfModule mod_negotiation.c>
选项-MultiViews
< / IfModule>
RewriteEngine On
#重定向尾部斜线如果不是文件夹...
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。* )/ $ / $ 1 [L,R = 301]
#处理前端控制器...
RewriteCond%{REQUEST_FILENAME}!-d
RewriteCond%{REQUEST_FILENAME}! - f
RewriteRule ^ index.php [L]
#句柄授权标题
RewriteC
我无法弄清楚我可能会在哪里查看'app /',而不是'/'。
我不知道服务器为什么认为您的根位于 / app
但是这个错误是因为Heroku应该为你的应用程序服务的 public /
目录的权限。
要解决此问题,只需将以下内容添加到作曲家的
脚本
部分.json
post-install-cmd:[
php artisan clear编译,
php artisan optimize,
chmod -R 777 public /
]
请注意 public /
目录的权限更改。
PS :我知道有些人真的很挑剔,并且会说权限过于宽松。是的,我同意你的看法。你可以把它改成别的东西,比如 775
让我们来看看果汁的流动情况。
I have deployed my laravel 5.4 app on Heroku. The problem is, I am getting this error message:
ForbiddenYou don't have permission to access / on this server
My Procfile:
web: vendor/bin/heroku-php-apache2 public/
Looking into the log, I find that it has been trying 'app/' instead of '/'.
My log, snipped for readability.
2017-12-03T14:18:45.747195+00:00 app[web.1]: [Sun Dec 03 14:18:45.746749 2017] [autoindex:error] [pid 122:tid 140692458305280] [client 10.140.221.43:41026] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive
My .htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteC
I can't figure out where i might be saying it to look into 'app/' instead of '/'. If that is the cause for this error.
I don't know why the server thinks your root is at /app
but this error occurs because of the permission of the public/
directory from which Heroku is supposed to serve your application.
To resolve this issue, simply add the following to the script
section of your composer.json
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize",
"chmod -R 777 public/"
]
Note the change in permission of the public/
directory.
PS: I know some people are really nitpicky and would say the permission is too lax. Yes, I agree with you. You can change it to something else like 775
let's just get the juice flowing.
这篇关于Laravel 5.4在Heroku上。禁止您无权访问/在此服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!