0

I have a Debian 11 server

On my website I have the following error:

Caused by: PDOException
could not find driver

According to what the phpinfo() function returns, my php.ini file is in:

/etc/php/7.4/apache2/php.ini

I have the following modules:

root@xxx:/var/www/html/xxx # php -m
[PHP Modules]
...
PDO
pdo_mysql
...

I have tried to uncomment the lines in the /etc/php/7.4/apache2/php.ini file: extension = mysqli and extension = pdo_mysql and then do service apache2 restart but it doesn't work

How can I load the driver?

  • If the wanted module is loaded but you still have an error, it's probably more something wrong in your code than a server configuration issue. Does it work elsewhere? – Chris Nov 28 '21 at 18:36
  • Yes, it is working on another server. The specific error occurs in `/var/www/html/xxx/vendor/yiisoft/yii2/db/Connection.php at line 723` The vendor folder is generated by `composer update`, it is not code developed by us. There are libraries and dependencies – Jorge Palacios Zaratiegui Nov 28 '21 at 20:31
  • If I run `phpinfo()` on my website it says that I have php 7.4.26. However if I run on the server `php -v` I have 8.0.13 version. Could the command `php -m` be confusing me? Is the module actually loaded? – Jorge Palacios Zaratiegui Nov 28 '21 at 20:37
  • Yes, it's possible the CLI version you are running is not the same as the apache version. In the phpinfo() the interesting part is the `PDO drivers` enabled in the `PDO` section. – Chris Nov 28 '21 at 20:56

0 Answers0