无法在 Apache2 PHP 7.4 上的 PDODb 上找到驱动程序

问题描述 投票:0回答:1

我正在使用 Ubuntu 22.04 和 php 7.4。我尝试使用 apache2 为我的网站虚拟托管。可以打开登录页面,在我们插入帐户后,错误显示

could not find driver
on /var/www/website/app/models/PDODb.php on line229 that line is

$this->pdo = new PDO($connectionString, $this->connectionParams['username'], $this->connectionParams['password'], $options);

我已经在 php.ini 上取消注释

extension=pdo_mysql
并且已经重新启动了 apache2。 使用
php -i | grep pdo_mysql
会导致这个

/etc/php/7.4/cli/conf.d/20-pdo_mysql.ini,
API Extensions => mysqli,pdo_mysql
pdo_mysql
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock

这是我的网站.conf

<VirtualHost *:80>

        ServerName localhost

        ServerAlias localhost
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/website
        DirectoryIndex /index.php index.php /index.html index.html
        <Directory "/var/www/website">
        AllowOverride All
        Require all granted
    </Directory>
   RewriteEngine on     
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

这是我用于连接到数据库的 config.php 定义(“DB_HOST”,“127.0.0.1”);

define("DB_USERNAME", "root");
define("DB_PASSWORD", "root123");
define("DB_NAME", "db_website");
define("DB_TYPE", "mysqli");
define("DB_PORT", "");
define("DB_CHARSET", "utf8");

我已经尝试过这个question但它仍然给我相同的结果。我该怎么办?

php mysql apache2
1个回答
0
投票

只需要把

define("DB_TYPE", "mysqli");
改成这个
define("DB_TYPE", "mysql");
因为我只有mysql_pdo

© www.soinside.com 2019 - 2024. All rights reserved.