gpt4 book ai didi

php - 配置 Azure 云服务上的 Wordpress 以通过 SSL 连接到 Azure MySQL

转载 作者:可可西里 更新时间:2023-11-01 08:02:46 28 4
gpt4 key购买 nike

我们在云服务上的主 .NET 解决方案的子文件夹中运行 Wordpress。我们已将 MySQL 从 CloudDB 移至 Azure MySQL,但是只有当我们将“强制 SSL 连接”设置为禁用时,它才会连接。

Wordpress wp-config.php 具有以下内容

define('DB_SSL', true);

我认为问题是我们需要传递证书,但我不清楚如何在 Wordpress 中设置此证书,以便在通过 SSL 连接时传递证书。

最佳答案

这是我所做的:

  1. Obtain SSL certificate并将证书文件保存到我的 Wordpress 项目的根目录中。

  2. 将以下内容添加到 wp-config.php 中:

    define('DB_SSL', true);
  3. 将其添加到我的 wp-includes/wp-db.php 中的函数 db_connect() 中。它必须在 mysqli_real_connect() 之前调用:

    // Just add this line
    mysqli_ssl_set($this->dbh, NULL, NULL, ABSPATH . 'BaltimoreCyberTrustRoot.crt.pem', NULL, NULL);

    if ( WP_DEBUG ) {
    mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
    } else {
    @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
    }

这个解决方案看起来有点脏,但它对我有用。

关于php - 配置 Azure 云服务上的 Wordpress 以通过 SSL 连接到 Azure MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47959933/

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