gpt4 book ai didi

php - PCF - 不允许应用程序在 MySQL 中创建表

转载 作者:行者123 更新时间:2023-11-29 17:47:23 26 4
gpt4 key购买 nike

我已成功将 Limesurvey.org 应用程序 (LAMP) 部署到 Pivotal Cloud。该应用程序基本上按预期工作,除了 MySQL 数据库不允许应用程序创建表。当激活给定的调查时,应用程序需要创建表来存储响应。

我已经在本地 (Linux) 安装了相同的应用程序,没有任何问题。另一个已将相同应用程序(不同版本)部署到 PCF 的团队建议我使用脚本(如下)捕获 VCAP_SERVICES 信息以连接数据库。然而,在“cf Push”之后,应用程序根本无法运行。这是一个 PHP 脚本。我在 Java 中似乎有类似的代码。

为什么我需要向 PCF 上的数据库提供 VCAP_SERVICES 信息?

也许如果我理解脚本想要做什么,我就能解决这个问题。

任何信息和/或提示将不胜感激。

class ApplicationConfiguration {
private static function decrypt_password($base64_encrypted_password, $cf_instance_ip, $uuid) {
$rsa_private_key = self::lookup_rsa_private_key ( $cf_instance_ip, $uuid );
$encrypted_password = base64_decode ( $base64_encrypted_password );
$decryption_result = openssl_private_decrypt ( $encrypted_password, $decrypted_password, $rsa_private_key );

return $decrypted_password;
}
private static function lookup_rsa_private_key($cf_instance_ip, $uuid) {
$private_key_lookup_url = 'http://' . $cf_instance_ip . ':1199/v1/cred/private_key/' . $uuid;

// SSL certificate is currently self-signed, disable all validation
$contextOptions = array (
'ssl' => array (
'verify_peer' => false,
'verify_peer_name' => false
)
);

$rsa_private_key = file_get_contents ( $private_key_lookup_url, false, stream_context_create ( $contextOptions ) );

return $rsa_private_key;
}
public static function getApplicationConfigurations() {
$appConfigurations = array ();

$dbDetails = getenv ( "VCAP_SERVICES" );

$appConfigurations ["debug"] = getenv ( "DEBUG" );
$appConfigurations ["debugsql"] = getenv ( "DEBUG_SQL" );

if (getenv ( "TABLE_PREFIX" ) == NULL) {
$appConfigurations ["tablePrefix"] = 'lime_';
} else {
$appConfigurations ["tablePrefix"] = getenv ( "TABLE_PREFIX" );
}

$dbDetailsObject = json_decode ( $dbDetails, true );

$credentials = array ();

if (array_key_exists ( "mariadb", $dbDetailsObject ) && $dbDetailsObject ["mariadb"] != NULL) {
$credentials = $dbDetailsObject ['mariadb'] [0] ["credentials"];
$appConfigurations ["connectionString"] = ('mysql:host=' . $credentials ["hostname"] . ';port=' . $credentials ["port"] . ';dbname=' . $credentials ["schema"] . ';');
} else {
$credentials = $dbDetailsObject ['p-mysql'] [0] ["credentials"];
$appConfigurations ["connectionString"] = ('mysql:host=' . $credentials ["hostname"] . ';port=' . $credentials ["port"] . ';dbname=' . $credentials ["name"] . ';');
}

$appConfigurations ["userName"] = $credentials ["username"];
$appConfigurations ["password"] = $credentials ["password"];

if (array_key_exists ( "appGuid", $credentials ) && $credentials ["appGuid"] != NULL) {
$cf_instance_ip = getenv ( "CF_INSTANCE_IP" );
$appConfigurations ["password"] = self::decrypt_password ( $credentials ["password"], $cf_instance_ip, $credentials ["appGuid"] );
}

return $appConfigurations;
}
}

最佳答案

这不是给db用户适当的权限的问题吗?

关于php - PCF - 不允许应用程序在 MySQL 中创建表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49699653/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com