CentOS 7.2, PHP 5.4 - MySQL extension is missing
Solution 1
Alright... finally, so it turns out all I needed to do was restart PHP-FastCGI. Yay.
systemctl restart php-fastcgi.service
Solution 2
Modern PHP applications use the mysqli
extension which supersedes the insecure (and now deprecated) mysql
extension. This should be enabled by default when you install the php-mysql
package but you can check it by running:
$ cat /etc/php.d/mysqli.ini
; Enable mysqli extension module
extension=mysqli.so
To be sure that this module is enabled, check that this module is listed in the PHP info page that you showed a sample of. Note that it’s listed further down the page in the modules section.
If you have the PHP command line interface installed (from the php-cli
package) you can easily check by running php -i | grep -i mysqli
. This should include the following line:
MysqlI Support => enabled
Related videos on Youtube
Sayem Khan
Updated on September 18, 2022Comments
-
Sayem Khan over 1 year
I'm trying to install a Wordpress blog on my Linux server (CentOS 7.2), using PHP 5.4 and MariaDB, but I keep running into this error:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Have been searching around for posts related to this:
- CentOS Linux 5.4 -Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Error when install Wordpress with mariadb "Your PHP installation appears to be missing the MySQL extension which is required by WordPress."
- Installing Wordpress in Rails /public - missing mysql extension
However, I already have php-mysql installed:
And I have the MySQL extension configured for php.ini:
But for some reason, the MySQL extension still isn't loading in phpinfo():
That's probably causing this error from Wordpress, any idea what might be happening? Why isn't the MySQL extension getting loaded in PHP? Maybe because I'm using MariaDB?
And here's the output of:
ls -l /etc/php.d , rpm -ql php-mysql and ls -l /usr/lib64/php/modules/
And the mysqli extension is installed and enabled:
-
Damiano Verzulli over 8 yearsPlease, can you provide the output of
ls -l /etc/php.d
,rpm -ql php-mysql
andls -l /usr/lib64/php/modules/
? As you're using CGI/FastCGI server-API, I want to be sure there are no file-permission problems. Also: are you running under SELINUX? -
Sayem Khan over 8 yearsI'm not running SELINUX, it's disabled. Just updated the post with those outputs, I have mysql and mysqli in all of those directories.
-
kasperd over 8 yearsPlease don't post screenshots of a terminal. Instead copy the text from the terminal to your question and use the code formatting feature.
-
IndieTech Solutions over 6 years` yum install php71w-mysqlnd`
-
Sayem Khan over 8 yearsJust updated the post with some more output, I do have the mysqli extension installed and enabled. However, I'm not seeing it show up in the PHP info page... any idea why it's not getting loaded?
-
Anthony Geoghegan over 8 years@SayemKhan That info looks fine. However, I've never ran PHP in CGI/FastCGI mode so I'm out of ideas. If I have time tomorrow evening (when I have access to a CentOS7 box), I'll try to replicate your set-up.
-
Sayem Khan over 8 yearsYup it turns out I forgot to restart PHP-FastCGI. Thanks for mentioning it and for your help.
-
godidier over 5 yearsThanks ! Had the exact same problem worked for me. Tho I used
systemctl restart php-fpm
. I am on Fedora 25