Heroku 上的 Laravel:它试图转到 /app/(403 禁止)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32399809/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:18:10  来源:igfitidea点击:

Laravel on Heroku: it's trying to go to /app/ (403 forbidden)

laravelherokuhomestead

提问by Diane Kaplan

I've created my first Laravel app and it works locally. The routes and controllers and stuff live in the app directory, and I see it at: http://homestead.app(I don't include /app in the url). I made it from these laracasts: https://laracasts.com/series/laravel-5-from-scratch

我已经创建了我的第一个 Laravel 应用程序,它可以在本地运行。路由和控制器等内容位于 app 目录中,我在以下位置看到它:http: //homestead.app(我没有在 url 中包含 /app)。我是从这些 laracasts 制作的:https://laracasts.com/series/laravel-5-from-scratch

The problem: I've successfully deployed it to Heroku, but when I go to the root url (https://dk-laravel-test.herokuapp.com), I get a 403 error:

问题:我已成功将其部署到 Heroku,但是当我转到根 url ( https://dk-laravel-test.herokuapp.com) 时,出现 403 错误:

Forbidden

You don't have permission to access / on this server.

Clues:

线索:

  1. According to the Papertrail log, it's actually trying to go to /app/but I'm not sure why- is that normal, or something that's inadvertently set somewhere?

    Sep 04 05:50:40 dk-laravel-test app/web.1: [Fri Sep 04 12:50:40.115461 2015] [autoindex:error] [pid 104:tid 140623923373824] [client 10.157.115.7:23446] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive

  2. when I put an index.php file at the root and then try to go there directly I get a 404 (not sure if that's a clue for this or a different problem): https://dk-laravel-test.herokuapp.com/index.php

  1. 根据 Papertrail 日志,它实际上试图转到 /app/但我不确定为什么 - 这是正常的,还是无意中设置的?

    9 月 4 日 05:50:40 dk-laravel-test app/web.1:[Fri Sep 04 12:50:40.115461 2015] [autoindex:error] [pid 104:tid 140623923373824] [client 10.134677] : 无法提供目录 /app/: 找不到匹配的 DirectoryIndex (index.php,index.html,index.htm),并且选项指令禁止服务器生成的目录索引

  2. 当我将 index.php 文件放在根目录然后尝试直接去那里时,我得到一个 404(不确定这是解决这个问题还是其他问题的线索):https: //dk-laravel-test.herokuapp.com /index.php

(3. I've previously added a little test php app to heroku and that served fine- nothing obvious jumps out comparing the two, but Laravel's obviously a lot fancier)

(3. 我之前在 heroku 中添加了一个小测试 php 应用程序并且效果很好 - 比较两者没有明显的跳跃,但 Laravel 显然更漂亮)

Question: where could I be accidentally telling it to go to /app/? Is that normal? Apologies if this is basic, it's my first rodeo and I've been looking around for hours

问题:我在哪里会不小心告诉它去 /app/?这是正常的吗?抱歉,如果这是基本的,这是我的第一次牛仔竞技表演,我已经环顾了几个小时

Other info/stuff I checked:- Following this article (https://mattstauffer.co/blog/installing-a-laravel-app-on-heroku), I set the BUILDPACK_URL, and in my Procfile I have:

我检查的其他信息/东西:- 按照这篇文章(https://mattstauffer.co/blog/installing-a-laravel-app-on-heroku),我设置了 BUILDPACK_URL,在我的 Procfile 中,我有:

web: vendor/bin/heroku-php-apache2 public

Any ideas? Where could I be accidentally telling it to go to /app/? Other stuff I should check? Any help is GREATLY appreciated!!

有任何想法吗?我在哪里会不小心告诉它去 /app/?其他我应该检查的东西?任何帮助是极大的赞赏!!

回答by Diane Kaplan

Answer: I think this had something to do with the Procfile being inaccessible:

答:我认为这与 Procfile 无法访问有关:

1) In the original case, my laravel app was one directory down in my git repo, so I think the Procfile was one level too deep to be actually found/used.

1) 在最初的情况下,我的 laravel 应用程序是我的 git 存储库中的一个目录,所以我认为 Procfile 太深了一层,无法实际找到/使用。

2) To verify whether that was it, I made a new (top-level) repo for a new Laravel app. I still saw the same /app/ symptom even when tweaking the Procfile(!), so I was stumped and frustrated. But this morning I updated Procfile again and pushed it to both github and heroku (should be unnecessary since I have automatic deploys set up for the master branch in that github repo), but now when I try to load it in a browser the path in the logs is (correctly) "/" instead of "/app/", so I'm finally onto the next step! (Remaining mystery that the Procfile still isn't actually listed in my github repo, but it shows up in the commit diff so the change did make it through)

2)为了验证是否是这样,我为一个新的 Laravel 应用程序创建了一个新的(顶级)存储库。即使在调整 Procfile(!) 时,我仍然看到相同的 /app/ 症状,所以我很困惑和沮丧。但是今天早上我再次更新了 Procfile 并将它推送到 github 和 heroku(应该是不必要的,因为我在那个 github repo 中为 master 分支设置了自动部署),但是现在当我尝试在浏览器中加载它时,路径日志是(正确地)“/”而不是“/app/”,所以我终于进入了下一步!(仍然是 Procfile 实际上并未在我的 github 存储库中列出,但它显示在提交差异中,因此更改确实通过了)

So I think Procfile was it :|

所以我认为是 Procfile :|