Heroku Procfile无法正常工作

时间:2015-04-06 23:52:05

标签: heroku procfile

我尝试使用Nginx + Phalcon。所以我有根文件夹(app)和我的公共文件夹(app / public)。

在root(app)中我有Procfile:

web: vendor/bin/heroku-php-nginx -C nginx_app.conf public/

在我的公共文件夹中,我有我的index.php

<?php exit('hello');

通过这个简单的例子,当我访问url myapp.herokuapp.com时,不应该打印你好吗?

如果我的想法是正确的,那是行不通的。我的第二个问题是nginx_app.conf似乎没有被服务器读取。因为我尝试访问的每个f *页面都有404。

那么,我做错了什么?

[增订]

这是日志:

heroku[web.1]: State changed from down to starting
heroku[web.1]: Starting process with command `php -S 0.0.0.0:57262`
heroku[web.1]: State changed from starting to up
app[web.1]: [Tue Apr  7 11:08:07 2015] 10.185.81.31:28258 Invalid request (Unexpected EOF)
app[web.1]: [Tue Apr  7 11:08:07 2015] 172.19.28.141:33686 Invalid request (Unexpected EOF)
heroku[router]: at=info method=GET path="/" host=myapp.herokuapp.com request_id=d39f119a-fd95-4887-809f-74712925606f fwd="200.221.158.131" dyno=web.1 connect=2ms service=4ms status=404 bytes=668
app[web.1]: [Tue Apr  7 11:08:44 2015] 10.61.196.230:38679 [404]: / - No such file or directory

[增订]

$ git push ...
[...]
remote: -----> Discovering process types
remote:        Procfile declares types -> web

$ heroku run bash
$ cat Procfile
~ $ : vendor/bin/heroku-php-nginx public/~ $

根据documentation应该是

heroku run bash
Running `bash` attached to terminal... up, run.5662
$ cat Procfile
web: vendor/bin/heroku-php-apache2

我尝试过的一些细节:

cat Procfile
~ $ vendor/bin/heroku-php-nginx public/c/~ $
vendor/bin/heroku-php-nginx public/
DOCUMENT_ROOT changed to 'public/'
Optimzing defaults for 1X dyno...
4 processes at 128MB memory limit.
Starting php-fpm...
Starting nginx...

我等着......让我们看看会发生什么

1 个答案:

答案 0 :(得分:2)

你的Procfile出了点问题;如您所见,Heroku正在默认的php -S模式下启动。如果存在Procfile,则会发生这种情况,但没有&#34; web&#34;流程类型已声明;这也应该写在git push heroku master的最后一条消息中(关于Procfile没有声明&#34; web&#34;进程类型然后使用默认值)。

这排除了您的Procfile未被检入Git或名称错误(例如小写procfile)。

罪魁祸首非常非常可能是您正在使用的编辑器插入文件开头的Unicode字节顺序标记:https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8

所以Procfile看起来不像这样:

web: vendor/bin/heroku-php-nginx -C nginx_app.conf public/

但实际上是这样的:

\0xEF\0xBB\0xBFweb: vendor/bin/heroku-php-nginx -C nginx_app.conf public/

您的编辑(以及大多数编辑)根本不显示BOM。

要解决此问题,请在没有BOM的情况下保存您的Procfile(并且,当您在其中时,将编辑器配置为永不保存UTF-8 BOM,因为它的使用非常不鼓励并且会导致无数问题像这样一个。)