为Heroku PHP应用程序更改文档根目录

时间:2014-07-12 20:47:53

标签: php heroku yii2

我正在创建一个Yii 2应用程序并在Heroku上尝试

文档根目录应该是该应用程序的Web /文件夹

这是我尝试过的:

  • 在该应用程序的根目录中创建一个Procfile
web:    sh www/config/web-boot.sh
  • 在配置文件夹中创建web-boot.sh
    echo "Include /app/www/config/httpd/*.conf" >> /app/apache/conf/httpd.conf
    touch /app/apache/logs/error_log
    touch /app/apache/logs/access_log
    tail -F /app/apache/logs/error_log &
    tail -F /app/apache/logs/access_log &
    export LD_LIBRARY_PATH=/app/php/ext
    export PHP_INI_SCAN_DIR=/app/www
    echo "Launching apache"
    exec /app/apache/bin/httpd -DNO_DETACH
  • 在config文件夹中,我创建了“httpd”文件夹,并在该文件夹中创建了“default.conf”
DocumentRoot "/app/www/web"
<Directory "/app/www/web">
         Options Indexes FollowSymLinks
         AllowOverride All
         Order allow,deny
         Allow from all
</Directory>

当我部署应用程序时,我收到此错误:


An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

当我查看日志时:

2014-07-12T20:23:08.476411+00:00 heroku[web.1]: State changed from starting to crashed
2014-07-12T20:23:06.313554+00:00 heroku[web.1]: Starting process with command `sh www/config/web-boot.sh`
2014-07-12T20:23:08.465571+00:00 heroku[web.1]: Process exited with status 2
2014-07-12T20:23:10.025168+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=richy-rich.herokuapp.com request_id=e4bb1124-5f2d-4a27-8df4-6fff9bc166b2 fwd="50.19.158.232" dyno= connect= service= status=503 bytes=
2014-07-12T20:41:49.308914+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=richy-rich.herokuapp.com request_id=5785ac83-c4fb-473e-b794-50ce491512c9 fwd="223.255.224.107" dyno= connect= service= status=503 bytes=

如何解决这个问题? 我完全不了解Procfile,谢谢

更新

现在我尝试了另一个解决方案,我将这个包添加到我的composer.json

heroku/heroku-buildpack-php

并将Procfile更改为:

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

这次我收到了这个错误:

2014-07-12T21:12:58.960392+00:00 app[web.1]: This program requires PHP 5.5.11 or newer; check your 'php' command.
2014-07-12T21:13:00.147518+00:00 heroku[web.1]: State changed from starting to crashed
2014-07-12T21:12:58.044158+00:00 heroku[web.1]: Starting process with command `vendor/bin/heroku-php-apache2 web/`
2014-07-12T21:13:00.136787+00:00 heroku[web.1]: Process exited with status 1
2014-07-12T21:13:08.648874+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=richy-rich.herokuapp.com request_id=a3bcc52d-2a7c-45ac-b21d-f856154d7e38 fwd="223.255.224.107" dyno= connect= service= status=503 bytes=

似乎这是因为我的PHP版本,因为heroku安装的版本是5.5.10,所以我尝试将作曲家php版本更新为“&gt; = 5.5.11”, 但我得到了另一个错误(男,这是4.39 AM,因为所有这些错误我还没有睡觉)

Problem 1
           - The requested package php could not be found in any version, there may be a typo in the package name.
         Problem 2
           - The requested package php could not be found in any version, there may be a typo in the package name.
         Problem 3
           - Installation request for cebe/markdown 0.9.x-dev -> satisfiable by cebe/markdown[0.9.x-dev].
           - cebe/markdown 0.9.x-dev requires php >=5.4.0 -> no matching package found.
         Problem 4
           - Installation request for ezyang/htmlpurifier v4.6.0 -> satisfiable by ezyang/htmlpurifier[v4.6.0].
           - ezyang/htmlpurifier v4.6.0 requires php >=5.2 -> no matching package found.
         Problem 5
           - Installation request for swiftmailer/swiftmailer 5.2.x-dev -> satisfiable by swiftmailer/swiftmailer[5.2.x-dev].
           - swiftmailer/swiftmailer 5.2.x-dev requires php >=5.2.4 -> no matching package found.
         Problem 6
           - Installation request for swiftmailer/swiftmailer dev-master -> satisfiable by swiftmailer/swiftmailer[dev-master].
           - swiftmailer/swiftmailer dev-master requires php >=5.2.4 -> no matching package found.
         Problem 7
           - Installation request for yiisoft/yii2 2.0.0-beta -> satisfiable by yiisoft/yii2[2.0.0-beta].
           - yiisoft/yii2 2.0.0-beta requires php >=5.4.0 -> no matching package found.
         Problem 8
           - yiisoft/yii2 2.0.0-beta requires php >=5.4.0 -> no matching package found.
           - yiisoft/yii2-swiftmailer 2.0.0-beta requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[2.0.0-beta].
           - Installation request for yiisoft/yii2-swiftmailer 2.0.0-beta -> satisfiable by yiisoft/yii2-swiftmailer[2.0.0-beta].
请帮助我,谢谢

1 个答案:

答案 0 :(得分:1)

您似乎并未使用官方buildpack,而是使用某种第三方(检查heroku config并查找BUILDPACK_URL)。

使用维护者对其进行排序,或者更好,使用Heroku的官方PHP支持(heroku config:unset BUILDPACK_URL并推送更改)。然后,您的Procfile将有效(但您需要删除heroku/heroku-buildpack-php中的composer.json依赖关系,或将其移至require-dev)。