Class "PDO" not found. Laravel 9 installation

SYSTEM INFORMATION
OS type and version CentOS Linux 7.9.2009
Virtualmin version Version 7.8.2

I’ve been trying to deploy a Laravel 9 (9.52.16) project into a server with Virtualmin, and after a lot of headaches (It’s amazing that there’s not a single clear and reliable tutorial on how to do that on the entire internet) I managed to have it let’s say, “responding”. I had to install php 8.0.30 because Laravel 9 doesn’t like any other php version. But I reached a point in where all I get is a " [Class “PDO” not found] when I go to the url


Asked chatGPT, Bard for solutions, and kept me giving me advices on what to do, nothing working. One of the advices was to add extension=pdo_mysql.so to the php.ini
But since then, what I get in the PHP Error Log is:

[22-Nov-2023 22:50:45 UTC] PHP Warning: PHP Startup: Unable to load dynamic library ‘pdo_mysql.so’ (tried: /opt/remi/php80/root/usr/lib64/php/modules/pdo_mysql.so (/opt/remi/php80/root/usr/lib64/php/modules/pdo_mysql.so: cannot open shared object file: No such file or directory), /opt/remi/php80/root/usr/lib64/php/modules/pdo_mysql.so.so (/opt/remi/php80/root/usr/lib64/php/modules/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Reinstalled php several times, and nothing.
By the way, Laravel won’t start with a previous php version (If someone knows how to do it, would be more than welcome) … so, totally out of ideas. Indeed not sure if I should post this here or in a Laravel forum or in a Centos forum.

Did you install the PHP mysql module for your version of PHP?

I went for

sudo yum install php-pdo php-mysql

with php 8.0.30 already installed and active
And the response was:

Loading mirror speeds from cached hostfile
Excluding mirror: mirror.fra1.de.leaseweb.net

So I guess, it is. By the way, in the same virtual server, phpMyAdmin is working, not sure if it uses another php version even me selecting php 8 as the version for that virtual server.

Well, after 3 days of not finding the solution, I finally found the package needed for it to work:

php80-php-mysqlnd

So I went for:

sudo yum install php80-php-mysqlnd

To get:

Installed:
php80-php-mysqlnd.x86_64 0:8.0.30-1.el7.remi
Dependency Installed:
php80-php-pdo.x86_64 0:8.0.30-1.el7.remi

  • Previously went for a:

sudo yum install php80

To install php 8

This was my solution, not sure if leave the answer for someone else that could have the same issue, or if I should just delete the post.

1 Like

Leave as it helps finding solutions.

1 Like

Please don’t delete posts, especially posts where a solution is posted.

This is a really helpful guide:

https://www.virtualmin.com/documentation/web/multiplephp/

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.