Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jlrdw's avatar
Level 75

Nginx php 7.4 not finding pdo driver

In Lubuntu with nginx I cannot seem to get pdo working.

In both php.ini files I did uncomment extension=pdo_mysql, and restarted all servers. PHP is served fine, just no pdo.

In /etc/php/7.4/mods-available there is pdo_mysql.ini :

; configuration for php mysql module
; priority=20
extension=pdo_mysql.so

A phpinfo(); shows PDO drivers no value.

Any ideas on why pdo isn't loading?

0 likes
11 replies
Sinnbeck's avatar

Be sure that you change the php.ini for fpm not cli/apache. Check the path using phpinfo()

jlrdw's avatar
Level 75

@Sinnbeck it is the one under fpm,and in the sites-available I have:

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

All works except pdo.

I can connect fine in dbeaver, so I know its not a mariadb connection issue.

Sinnbeck's avatar

@jlrdw yeah definitely a missing module What happens if you try to install it with apt or pecl?

jlrdw's avatar
Level 75

@Sinnbeck php 7.4 came with lubuntu. I have tried to uninstall and reinstall ** php7.4-mysql** with no change.

Side note I have nginx and apache both on Windows 11 with php 8.1 but no problems.

I am new to linux, so I want to upgrade to php 8.1, but I don't all the steps yet.

On Windows, everything is just unzipped and ready to go in 5 minutes. Linux with nginx is a little more involved. Would you suggest completely uninstalling php 7.4 and install 8.1 from scratch?

Also I tried and played with apache first, it all worked good. But I removed apache to learn nginx on linux.

Also as you know in windows, non thread safe is for nginx. But from what I can see, there's only a single version for nginx and apache in linux, is that correct?

I have only had this lubuntu setup a few days now.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@jlrdw I suggest installing the ppa for php to get the proper version of everything :)

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php8.1 php8.1-mysql

If you are new to linux then a PPA is like a download location for apps. The build in version of php in ubuntu is very old and outdated, so the community runs a PPA that is always up to date with the newest version :)

jlrdw's avatar
Level 75

@Sinnbeck I will try that tomorrow. And is it possible to upgrade to php 8.1?

Sinnbeck's avatar

@jlrdw Changed the example to 8.1 :) It should set the active version to 8.1 when installed. If not you can change it with

sudo update-alternatives --set php /usr/bin/php.8.1
jlrdw's avatar
Level 75

@Sinnbeck I never got php 7.4 to work, but php 8.1 worked right away. I did however have to also install:

  • php8.1-fpm

Funny thing is I saw where others had similar problems on stackoverflow, and changing to php 8 or 8.1 fixed all problems.

Please or to participate in this conversation.