PHP网站不再在Heroku上运行:错误500

我正在尝试将我用普通PHP 7.2.1编写的应用程序推送到Heroku。我使用apache和mariaDB在本地docker容器中开发,一切正常。当我进入Heroku时,将加载索引页面,但是如果我尝试登录或进入任何其他页面,则没有任何效果,并且我得到一个空白页面。我使用clearDB附加组件,并仅通过CLI在其中导入了mariaDB .sql导出文件。该网站使用URL重写,路由器和.htaccess。

我在这里已经阅读了其他问题,看来问题可能来自多个角度。不幸的是,我是很多新手,我很难理解错误日志。我认为这些(或全部)中的任何一个都可能是错误的:

  • .htaccess可能引起的问题
  • 缺少composer.json文件,因此服务器端配置错误
  • 数据库连接到应用程序的方式可能冲突
  • 根据以下信息,我应该/应该如何对应用程序进行故障排除?

    这是我的.htaccess:

    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9-_/]*)$ index.php?id=$1 [QSA,L] 
    

    这是构建日志:

    -----> PHP app detected
    
     !     WARNING: No 'composer.json' found!
     !     Your project only contains an 'index.php',no 'composer.json'.
     !     Using 'index.php' to declare app type as PHP is deprecated and
     !     may lead to unexpected behavior.
     !     Please consider updating your codebase to utilize Composer and
     !     modern dependency management in order to benefit from the latest
     !     PHP runtimes and improved application performance,as well as
     !     control over the PHP versions and extensions available.
    
     !     For an introduction to dependency management with Composer and
     !     how to get the most out of PHP on Heroku,refer to the docs at
     !     https://getcomposer.org/doc/00-intro.md and
     !     https://devcenter.heroku.com/articles/getting-started-with-php
    
    -----> Bootstrapping...
    -----> Installing platform packages...
           NOTICE: No runtime required in composer.lock; using PHP ^7.0.0
           - php (7.3.11)
           - apache (2.4.41)
           - nginx (1.16.1)
    -----> Installing dependencies...
           Composer version 1.9.0 2019-08-02 20:55:32
    -----> Preparing runtime environment...
           NOTICE: No Procfile,using 'web: heroku-php-apache2'.
    -----> Checking for additional extensions to install...
    -----> Discovering process types
           Procfile declares types -> web
    -----> Compressing...
           Done: 18.5M
    -----> launching...
           Released v5
           https://cogip-becode.herokuapp.com/ deployed to Heroku
    

    这是应用程序日志:

    2019-11-08T12:59:03.464108+00:00 heroku[router]: at=info method=GET path="/assets/css/style.css" host=cogip-becode.herokuapp.com request_id=527c0174-09a9-42c9-9a08-4253b4baa78d fwd="84.198.194.106" dyno=web.1 connect=1ms service=1ms status=304 bytes=128 protocol=https
    
    2019-11-08T12:59:08.532874+00:00 heroku[router]: at=info method=POST path="/" host=cogip-becode.herokuapp.com request_id=d7eea251-3d27-49c5-bd54-75d9583b3dd4 fwd="84.198.194.106" dyno=web.1 connect=1ms service=3ms status=500 bytes=279 protocol=https
    
    2019-11-08T12:59:08.533394+00:00 app[web.1]: [08-Nov-2019 12:59:08 UTC] PHP Notice:  Undefined index: id in /app/index.php on line 4
    
    2019-11-08T12:59:08.533891+00:00 app[web.1]: [08-Nov-2019 12:59:08 UTC] PHP Parse error:  syntax error,unexpected 'cleardb' (T_STRING) in /app/database/connection.php on line 3
    
    2019-11-08T12:59:08.534564+00:00 app[web.1]: 10.11.238.43 - - [08/Nov/2019:12:59:08 +0000] "POST / HTTP/1.1" 500 - "https://cogip-becode.herokuapp.com/" "Mozilla/5.0 (X11; Linux x86_64; rv:60.9) Gecko/20100101 goanna/4.4 Firefox/60.9 PaleMoon/28.7.1
    
    koto21cn 回答:PHP网站不再在Heroku上运行:错误500

    暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
    本文链接:https://www.f2er.com/3128162.html

    大家都在问