【问题标题】:I can't deploy my php app to Heroku我无法将我的 php 应用程序部署到 Heroku
【发布时间】:2020-01-06 17:06:16
【问题描述】:

这是我第一次接触 Heroku(真的很棒)。 我按照这些步骤将我的第一个应用程序部署到 heroku。

git init
git add .
git commit -m 'first commit'
heroku create abcfirstapp
git remote add origin git@heroku.com:abcfirstapp.git
git push heroku master

我得到了像

这样的错误

Heroku 推送被拒绝,未检测到 Cedar 支持的应用 到 git@heroku.com:abcfirstapp.git [remote.rejected] master -> master (pre-receive hook denied) 错误:未能将一些引用推送到 'git@heroku.com:abcfirstapp.git'

我很确定我的 php 文件可能是编写的,因为它在我的本地 xampp 服务器上运行良好

<?PHP phpinfo(); ?>

另一个问题是:当我尝试从 heroku 中提取时使用

git pull heroku master

我遇到了一个错误

致命:找不到远程参考主机

谁能帮帮我?

谢谢

【问题讨论】:

    标签: php heroku


    【解决方案1】:

    默认的 PHP buildpack 在 repo 根目录中通过 looking for index.php 检测 PHP 应用程序。你有其中之一吗?

    或者,您可以对 buildpack 进行硬编码:

    heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
    

    【讨论】:

    • 嗨,这真的很有帮助。顺便说一句,你能向我解释一下 index.php 的目的以及 index.php 的样子吗?
    • 当 Heroku 获取您的应用程序源代码时,它必须决定在构建您的应用程序 slug 时使用哪个 buildpack(即 Ruby、Python 等)。为了检测是否使用 PHP buildpack(这是您想要的),它会寻找一个名为 index.php 的文件,因为大多数 PHP 应用程序都倾向于拥有它。
    【解决方案2】:

    未检测到 Cedar -- 支持的应用

    PHP 不是 Heroku 上原生支持的语言,我想除了 Facebook 应用程序之外。您需要使用Third Party Buildpack 之类的东西。

    【讨论】:

      【解决方案3】:

      看起来文档(2015 年 4 月)建议您通过以下方式设置自定义 buildpack:

      heroku buildpack:set https://github.com/heroku/heroku-buildpack-php

      https://devcenter.heroku.com/articles/buildpacks

      【讨论】:

        【解决方案4】:

        至少需要一个空的composer.json推送这个,然后重新部署

        【讨论】:

          猜你喜欢
          • 2017-08-27
          • 2018-12-12
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-10-25
          • 1970-01-01
          相关资源
          最近更新 更多