这是一个纯粹的Bluemix问题!
我已经在本地主机上顺利运行代码但是当我将其迁移到Bluemix时,我的数据库连接失败了。 检查日志我发现问题“调用未定义的函数mysqli_init()”HTTP响应500.我发现该扩展已被禁用,使其变小并找到了一些有关它的详细信息: Buildpack选项 。
不幸的是我尝试过但失败了。 也许我误解了解决方案。
任何帮助将不胜感激。
编辑:
bgconfig - > bp-config解决了“未定义的函数错误”
似乎已经添加了一些扩展,但并非全部。 “致命错误:在第15行的/home/vcap/app/htdocs/db_config.php中找不到类'PDO'”
但是我在options.json中添加了PDO扩展。
我尝试添加一个php.ini覆盖
但仍然得到同样的错误......
有关信息:db_config.php上的第15行只是:
$db = new PDO('mysql:host=us-cdbr-iron-east-02.cleardb.net;dbname=ad_dae231843a962ca', $username, $password);}在尝试和捕捉当然。
任何线索?
This is a purely Bluemix question!
I've got code running smoothly on a localhost but when I migrated it to Bluemix my DB connection failed me. Checking the logs I found the issue "Call to undefined function mysqli_init()" HTTP response 500. I have found out that extension have been disabled to make it smaller and have found some details about it: Buildpack options.
Unfortunately I have tried that and failed. Maybe I have misunderstood the solution.
Any Help would be greatly appreciated.
EDIT:
bgconfig --> bp-config solved the "undefined function error"
It seems that some extension have been added but not all. "Fatal error:Class 'PDO' not found in /home/vcap/app/htdocs/db_config.php on line 15"
I have however added the PDO extension in options.json.
I tried adding a php.ini overwrite
But still get the same error...
For info: line 15 on db_config.php is simply:
$db = new PDO('mysql:host=us-cdbr-iron-east-02.cleardb.net;dbname=ad_dae231843a962ca', $username, $password);}within try & catch of course.
Any Clues?
最满意答案
您发布的options.json文件是正确的。 但是它位于错误的目录中,它应该位于名为.bp-config/的文件夹中。 重命名该文件夹并将您的应用程序重新注册回Bluemix。
还可以尝试将pdo_mysql添加到.bp-config/options.json 。
我刚刚使用PDO驱动程序对数据库测试了一些代码并且工作正常。 我的.bp-config/options.json文件如下。
{ "PHP_EXTENSIONS": ["pdo", "mysqli", "pdo_mysql", "mysql"] }我会使用MySQL桌面客户端仔细检查您对数据库的访问。 它看起来像您的连接信息的问题。
我有一个示例应用程序用于测试与PDO的连接信息。
The options.json file is correct that you have posted. However it is in the wrong directory, it should be in a folder called .bp-config/. Renamed the folder and repush your app back to Bluemix.
Also try adding pdo_mysql to .bp-config/options.json.
I just tested some code with the PDO driver against a DB and it worked fine. My .bp-config/options.json file is below.
{ "PHP_EXTENSIONS": ["pdo", "mysqli", "pdo_mysql", "mysql"] }I would double check your access to the database with a MySQL desktop client. It looks like an issue with your connection information.
I have an example app for testing your connection information with PDO.
更多推荐
发布评论