php - 数据超过 2MB 的发布请求出现错误 Heroku
问题描述
我的 PHP 应用程序在 heroku 上运行。php 应用程序正在运行代码点火器框架。我有一个第三方合作伙伴将文件发送到我允许他们发布数据的功能。
它是codeigniter控制器上的一个普通php函数。
public function getting_third_party_data(){
// Fetching all information from the post request and saving to db
}
问题是,每当他们发送低于 2MB 的数据时,它工作得非常好,但是当它超过 2MB 时,我的应用程序会发送一个内部服务器错误。
我联系了heroku的人,但他们停止回复了2-3周,所以我在这里问。
我添加了.user.ini
具有以下参数的文件
memory_limit = 32M
upload_max_filesize = 10M
post_max_size = 20M
即使在此之后,每当我的应用程序收到超过 2MB 的数据时,它都会显示内部服务器错误。
解决方案
对于那些尝试过.user.ini
解决方案(https://stackoverflow.com/a/28897926/7092969)但它不起作用的人:
我们的 Laravel 应用程序由 Apache 或 Nginx 执行。这可以通过Procfile
根目录中的 Heroku 进行更改:
- 让我们
nginx.conf
在根目录中创建并添加以下内容:
client_max_body_size 25M;
location / {
# try to serve file directly, fallback to rewrite
try_files $uri @rewriteapp;
}
location @rewriteapp {
# rewrite all to index.php
rewrite ^(.*)$ /index.php/$1 last;
}
location ~ ^/index\.php(/|$) {
try_files @heroku-fcgi @heroku-fcgi;
# ensure that /index.php isn't accessible directly, but only through a rewrite
internal;
}
- 将
Procfile
内容设置为:
web: vendor/bin/heroku-php-nginx -C nginx.conf public/
重新部署 Heroku 应用程序
干杯! :)
推荐阅读
- sql - 创建每月所有天的列表并将值平均分配给每一天
- facebook-graph-api - 将视频上传到我自己的页面的权限(作为管理员/开发人员)
- python - 使用 django 块时如何使用 div
- sql-server - CASE WHEN @Filter = 'Department' THEN Employee.Department END BETWEEN @From AND @To
- java - 从 Kafka 主题读取数据时,Avro 反序列化失败
- graph-algorithm - Dijkstra的算法,当它们具有相同长度时如何选择下一个节点
- pytest - Pytest --collect-only -q 忽略跳过的测试
- php - 部署到 EC2 后 Laravel App 错误 503
- arrays - 使用索引比较 v-for 中的前一个数组值不断抛出未定义
- html - 输入:检查未作用于标签 CSS