heroku 上的 Symfony 部署指向 app 文件夹

Symfony deployment on heroku points to app folder

我正在尝试在 heroku 上部署 symfony 应用程序,我能够更新模式并且一切都很好但是当我尝试访问该站点时我得到

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

所以使用命令 heroku logs --num 10 我可以看到错误

Cannot serve directory /app/web/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive

如您所见,heroku 正在尝试访问 /app/web/ 而不仅仅是 web,因此即使我的资产也在通过 app/web/css 访问,这当然是错误的。

那么我怎样才能摆脱这个 app?我不明白为什么 Heroku 甚至指着那个。

我已经一遍又一遍地完成了 Symfony documentation 中提到的步骤,但我似乎无法找出我遗漏了什么?

Procfile 似乎指向网络,所以这个 app 来自哪里?

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

我已经阅读了其他在线文章,例如下面的文章,但似乎无法解决我的问题。

任何帮助将不胜感激。

使用 /web/ 而不是 web/:添加前导斜杠!

您的 Procfile 文件应包含以下内容:

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

注意 web 文件夹路径中的前导 /

在 Heroku 上您需要创建 .Procfile 并上传 创建 app.json Schema file and then based on that Heroku will create the .Procfile for you automatically, here 您可以看到 app.json Symfony 应用程序示例。

另一件需要交叉检查的事情是确保在您的 public 目录中也上传了 .htaccess 文件。在 Symfony 中,public 目录是 web 文件夹,在我的例子中,.htaccess 文件丢失了。

确保以上两个步骤后,我的应用程序在 Heroku 上运行良好。