Score:0

How to set pdo driver in apache?

bd flag

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?

Chris avatar
it flag
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?
Jorge Palacios Zaratiegui avatar
bd flag
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 avatar
bd flag
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?
Chris avatar
it flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.