Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/plugins/system/falangdriver/falangdriver.php on line 534
安装 MySQLi 扩展 - Bluetooth forum - bluetooth蓝牙技术

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/html/components/com_comprofiler/plugin/user/plug_cbjdownloads/cbjdownloads.php on line 49

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/html/components/com_comprofiler/plugin/user/plug_cbblogs/cbblogs.php on line 48

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/html/components/com_comprofiler/plugin/user/plug_cbarticles/cbarticles.php on line 47

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323
Technical discuss

安装 MySQLi 扩展


Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/cbPluginHandler.php on line 323
  • btt
  • [btt]
  • 帖子作者
  • 新手上路
  • 新手上路
更多
2026-01-05 12:53 #983 by btt
新帖
# 安装 PHP 8.4 的 MySQLi 扩展
sudo apt install php8.4-mysql

# 或者安装通用版本(系统自动匹配)
sudo apt install php-mysql

# 重启 Web 服务(如果使用)
sudo systemctl restart apache2
# 或
sudo systemctl restart nginx

----验证 MySQLi 是否已安装
# 检查 MySQLi 是否已加载
php -m | grep -i mysqli

# 或者使用 PHP 代码测试
Code:
php -r ' echo "MySQLi 扩展: " . (extension_loaded("mysqli") ? "✅ 已加载" : "❌ 未加载") . "\n"; echo "PDO MySQL: " . (extension_loaded("pdo_mysql") ? "✅ 已加载" : "❌ 未加载") . "\n"; '
安装所有必需的 PHP 扩展(一站式解决)
Code:
# 安装所有 Joomla 5 必需的扩展 sudo apt install -y \     php8.4 \     php8.4-mysql \     php8.4-xml \     php8.4-curl \     php8.4-mbstring \     php8.4-zip \     php8.4-gd \     php8.4-intl \     php8.4-bcmath \     php8.4-opcache \     php8.4-soap
检查 MySQL/MariaDB 服务器状态
# 检查 MySQL/MariaDB 是否已安装并运行
sudo systemctl status mysql

# 如果没有安装,安装 MySQL
sudo apt install mysql-server -y

# 启动并启用 MySQL
sudo systemctl start mysql
sudo systemctl enable mysql

# 检查 PHP 是否可以连接 MySQL
php -r '
$link = @mysqli_connect("localhost", "root", "");
if ($link) {
    echo "✅ 可以连接到 MySQL 服务器\n";
    mysqli_close($link);
} else {
    echo "❌ 无法连接到 MySQL: " . mysqli_connect_error() . "\n";
}
'配置 MySQL 用户(如果需要)# 安全配置 MySQL(设置 root 密码等)
sudo mysql_secure_installation

# 登录 MySQL
sudo mysql -u root

# 在 MySQL 命令行中创建 Joomla 用户
# (根据实际情况调整用户名和密码)
CREATE DATABASE joomla_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'joomla_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON joomla_db.* TO 'joomla_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
完整环境检查脚本
cat > check_joomla_env.php << 'EOF'
<?php
echo "=== Joomla 5 环境检查 ===\n\n";

// 检查 PHP 版本
$php_version = PHP_VERSION;
echo "PHP 版本: $php_version ";
echo version_compare($php_version, '8.0.0', '>=') ? "✅\n" : "❌ (需要 8.0+)\n";

// 检查必需扩展
$required_extensions = [
    'mysqli' => 'MySQL 数据库连接',
    'pdo_mysql' => 'PDO MySQL 支持',
    'simplexml' => 'XML 解析',
    'dom' => 'DOM 文档',
    'xml' => 'XML 支持',
    'json' => 'JSON 处理',
    'mbstring' => '多字节字符串',
    'curl' => 'HTTP 请求',
    'openssl' => '加密',
    'zlib' => '压缩',
    'gd' => '图像处理',
    'intl' => '国际化',
    'zip' => 'ZIP 压缩',
];

echo "\n=== 扩展检查 ===\n";
foreach ($required_extensions as $ext => $desc) {
    echo $ext . ": " . (extension_loaded($ext) ? "✅" : "❌") . " ($desc)\n";
}

// 检查目录权限
echo "\n=== 目录权限检查 ===\n";
$directories = [
    '/var/www/html' => '网站根目录',
    '/var/www/html/administrator' => '后台目录',
    '/var/www/html/tmp' => '临时目录',
    '/var/www/html/logs' => '日志目录',
    '/var/www/html/cache' => '缓存目录',
];

foreach ($directories as $dir => $desc) {
    if (is_dir($dir)) {
        $writable = is_writable($dir);
        echo $dir . ": " . ($writable ? "✅ 可写" : "❌ 不可写") . " ($desc)\n";
    } else {
        echo $dir . ": ❌ 不存在 ($desc)\n";
    }
}

// 检查 MySQL 连接
echo "\n=== MySQL 连接测试 ===\n";
try {
    $link = mysqli_connect("localhost", "root", "");
    if ($link) {
        echo "✅ MySQL 服务器可连接\n";
        echo "MySQL 版本: " . mysqli_get_server_info($link) . "\n";
        mysqli_close($link);
    } else {
        echo "❌ 无法连接 MySQL: " . mysqli_connect_error() . "\n";
    }
} catch (Exception $e) {
    echo "❌ MySQL 连接异常: " . $e->getMessage() . "\n";
}

echo "\n=== 内存限制 ===\n";
echo "memory_limit: " . ini_get('memory_limit') . "\n";
echo "upload_max_filesize: " . ini_get('upload_max_filesize') . "\n";
echo "post_max_size: " . ini_get('post_max_size') . "\n";

echo "\n=== 建议 ===\n";
if (!extension_loaded('mysqli')) {
    echo "1. 运行: sudo apt install php8.4-mysql\n";
}
if (!extension_loaded('simplexml')) {
    echo "2. 运行: sudo apt install php8.4-xml\n";
}
EOF

# 运行环境检查
php check_joomla_env.php一键修复所有问题
cat > fix_all_for_joomla.sh << 'EOF'
#!/bin/bash
echo "=== Joomla 5 环境一键修复 ==="

# 更新系统
echo "更新系统包..."
sudo apt update -o Acquire::Check-Valid-Until=false

# 安装所有必需扩展
echo "安装 PHP 扩展..."
sudo apt install -y \
    php8.4 \
    php8.4-mysql \
    php8.4-xml \
    php8.4-curl \
    php8.4-mbstring \
    php8.4-zip \
    php8.4-gd \
    php8.4-intl \
    php8.4-bcmath \
    php8.4-opcache

# 安装 MySQL 服务器(如果未安装)
if ! systemctl is-active --quiet mysql; then
    echo "安装 MySQL 服务器..."
    sudo apt install -y mysql-server
    sudo systemctl start mysql
    sudo systemctl enable mysql
fi

# 设置目录权限
echo "设置目录权限..."
cd /var/www/html
sudo chown -R www-data:www-data .
sudo chmod -R 755 .
sudo chmod 777 tmp cache logs

# 重启服务
echo "重启服务..."
if systemctl is-active --quiet apache2; then
    sudo systemctl restart apache2
elif systemctl is-active --quiet nginx; then
    sudo systemctl restart nginx
fi

# 验证
echo "验证安装..."
php -m | grep -E "mysqli|simplexml|curl|mbstring"

echo "修复完成!"
EOF

# 运行修复脚本
chmod +x fix_all_for_joomla.sh
sudo ./fix_all_for_joomla.sh最后尝试安装扩展包
# 回到 Joomla 目录
cd /var/www/html

# 先测试 Joomla CLI 是否正常工作
php cli/joomla.php --help

# 尝试安装扩展包
php cli/joomla.php extension:install pkg_socialpay_j5_v3.0.0.zip

# 如果还有问题,查看详细错误
php cli/joomla.php extension:install pkg_socialpay_j5_v3.0.0.zip --debug 2>&1常见问题解决方案如果仍然报错 "MySQLi extension is not available":
# 检查 MySQLi 扩展是否在 php.ini 中启用
php --ini | grep "Loaded Configuration"

# 查看具体的 php.ini 文件
grep -i mysqli /etc/php/8.4/cli/php.ini

# 如果找不到,手动添加
echo "extension=mysqli" | sudo tee /etc/php/8.4/cli/conf.d/20-mysqli.ini

# 重新检查
php -m | grep mysqli检查 PHP CLI 和 Web PHP 的区别:
# 创建 PHP 信息文件
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

# 通过浏览器访问 http://your-site/phpinfo.php
# 查看 "Configuration File (php.ini) Path" 和加载的扩展
# 确保 Web 服务器也加载了 mysqli 扩展

# 安装 Web 服务器用的扩展
sudo apt install libapache2-mod-php8.4 php8.4-fpm -y安装成功后的验证 总结 您遇到的主要问题及解决步骤:
  1. 缺少 SimpleXML 扩展 ✅ 已解决(通过 php-xml)
  2. 缺少 MySQLi 扩展 ❌ 需要安装
请运行以下命令:

# 安装 MySQLi 扩展
sudo apt install php8.4-mysql -y

# 验证安装
php -m | grep mysqli

# 然后重新尝试安装
cd /var/www/html
php cli/joomla.php extension:install pkg_socialpay_j5_v3.0.0.zip --debug

​​​​​​​
如果安装成功,您应该能看到类似 "Extension package installed successfully" 的消息。








 

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/LegacyFoundationFunctions.php on line 234

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/LegacyFoundationFunctions.php on line 237

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/LegacyFoundationFunctions.php on line 239

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/LegacyFoundationFunctions.php on line 189

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/LegacyFoundationFunctions.php on line 237

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/html/libraries/CBLib/CB/Legacy/LegacyFoundationFunctions.php on line 239

登录注册一个帐号 参加讨论

核心: Kunena 论坛
FaLang translation system by Faboba

Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/plugins/system/falangdriver/falangdriver.php on line 100

Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/plugins/system/falangdriver/falangdriver.php on line 100
mysqli object is already closed (500 Whoops, looks like something went wrong.)

Error

HTTP 500 Whoops, looks like something went wrong.

mysqli object is already closed

Exception

Error

  1. */
  2. public function disconnect()
  3. {
  4. // Close the connection.
  5. if (\is_callable([$this->connection, 'close'])) {
  6. $this->connection->close();
  7. }
  8. parent::disconnect();
  9. }
  1. */
  2. public function disconnect()
  3. {
  4. // Close the connection.
  5. if (\is_callable([$this->connection, 'close'])) {
  6. $this->connection->close();
  7. }
  8. parent::disconnect();
  9. }
  1. *
  2. * @since 2.0.0
  3. */
  4. public function __destruct()
  5. {
  6. $this->disconnect();
  7. }
  8. /**
  9. * Alter database's character set.
  10. *
DatabaseDriver->__destruct()

Stack Trace

Error
Error:
mysqli object is already closed

  at /var/www/html/libraries/vendor/joomla/database/src/Mysqli/MysqliDriver.php:318
  at mysqli->close()
     (/var/www/html/libraries/vendor/joomla/database/src/Mysqli/MysqliDriver.php:318)
  at Joomla\Database\Mysqli\MysqliDriver->disconnect()
     (/var/www/html/libraries/vendor/joomla/database/src/DatabaseDriver.php:496)
  at Joomla\Database\DatabaseDriver->__destruct()                

Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/plugins/system/falangdriver/falangdriver.php on line 100

Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/plugins/system/falangdriver/falangdriver.php on line 100