Heroku Procfile 不工作
Heroku Procfile not working
我正在尝试使用 Nginx + Phalcon。所以我有根文件夹 (app) 和我的 public 文件夹 (app/public).
在根目录(应用程序)中我有 Procfile:
web: vendor/bin/heroku-php-nginx -C nginx_app.conf public/
在我的 public 文件夹中有我的 index.php
<?php exit('hello');
用这个简单的例子,当我访问 url myapp.herokuapp.com 时不应该打印 hello?
如果我的想法是对的,那就行不通了。我的第二个问题是 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...
我在等...让我们看看会发生什么
你的Procfile
出了点问题;如您所见,Heroku 以默认 php -S
模式启动。当存在 Procfile
但未声明 [=36=] 进程类型时,会发生这种情况;这也应该写在 git push heroku master
末尾的消息中(关于 Procfile
未声明 [=36=] 进程类型然后使用默认值)。
这排除了您的 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/
但实际上是这样的:
[=11=]xEF[=11=]xBB[=11=]xBFweb: vendor/bin/heroku-php-nginx -C nginx_app.conf public/
您的编辑器(以及与此相关的大多数编辑器)根本不显示 BOM。
要解决此问题,请在不使用 BOM 的情况下保存 Procfile
(并且,在您这样做的同时,将您的编辑器配置为从不保存 UTF-8 BOM,因为强烈建议不要使用它并导致无数就像这个问题一样)。
我正在尝试使用 Nginx + Phalcon。所以我有根文件夹 (app) 和我的 public 文件夹 (app/public).
在根目录(应用程序)中我有 Procfile:
web: vendor/bin/heroku-php-nginx -C nginx_app.conf public/
在我的 public 文件夹中有我的 index.php
<?php exit('hello');
用这个简单的例子,当我访问 url myapp.herokuapp.com 时不应该打印 hello?
如果我的想法是对的,那就行不通了。我的第二个问题是 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...
我在等...让我们看看会发生什么
你的Procfile
出了点问题;如您所见,Heroku 以默认 php -S
模式启动。当存在 Procfile
但未声明 [=36=] 进程类型时,会发生这种情况;这也应该写在 git push heroku master
末尾的消息中(关于 Procfile
未声明 [=36=] 进程类型然后使用默认值)。
这排除了您的 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/
但实际上是这样的:
[=11=]xEF[=11=]xBB[=11=]xBFweb: vendor/bin/heroku-php-nginx -C nginx_app.conf public/
您的编辑器(以及与此相关的大多数编辑器)根本不显示 BOM。
要解决此问题,请在不使用 BOM 的情况下保存 Procfile
(并且,在您这样做的同时,将您的编辑器配置为从不保存 UTF-8 BOM,因为强烈建议不要使用它并导致无数就像这个问题一样)。