1

I have a wordpress site on windows server. I moved it on ubuntu server but take an error "Your PHP installation appears to be missing the MySQL extension which is required by WordPress."

I did some research for fix it and founded "you must install php5-mysql pacakage". Why? I have already installed php-mysql package.

important note: There is good working another wordpress site on same server.

important note: Nginx - MySql - Php7.0 are installed on ubuntu server

please help me?

Mr.Ayanlar
  • 450
  • 1
  • 6
  • 12

3 Answers3

0

You have to have a way to talk to MySQL. There's only two ways to do that

  1. Through the MySQL Client (i.e. php5-mysql). This is the older way to do it. PHP unbundled MySQL so this route also requires you to install mysql-client (or whatever equivalent your distro uses) since it talks to MySQL though the client.
  2. Through the MySQL Native Driver (i.e. php5-mysqlnd). This way is preferred, since it is a core part of PHP now. This way PHP directly communicates with MySQL without an intermediary. Also, some parts of mysqli work better with this installed

It sounds like this is Ubuntu and PHP7. So you might need something like php7-mysqlnd

Machavity
  • 30,841
  • 27
  • 92
  • 100
0

Wordpress only checks for availability of mysql_* functions. If you are getting this error they are not available.

If you really installed php-mysql metapackage (which I hope actually installs php7.0-mysql) and you have mysql mod available in apache mods_available folder, it's not simply not enabled. You need to add a link to mods_enabled and restart the server.

BTW, you can check enabled mods with php_info().

Hope this helps.

Boris Schegolev
  • 3,601
  • 5
  • 21
  • 34
0

I have a feeling, that you have 2 PHP installations on your server, namely php5.6 and php7.0. Since there is presence of php7.0 and you do not seem to have used (based on the way you described the problem) custom source.list to achieve this I presume that you have Ubuntu 16.04 installed.

The following commands on your Ubuntu 16.04 server should resolve this issue for you:

apt install php7.0-mysql
service php7.0-fpm restart
service nginx restart

However, if you indeed have active php5 installed and activated, you should check if your php-fpm pool is using a different version. You can check this by looking into file:

/etc/php/7.0/fpm/pool.d/www.conf

Additionally, you can update your question with additional details, by running the following commands on your server and sharing with us their output:

lsb_release -a (determines Ubuntu version)
which php (determines which php is loaded in the command line)
service --status-all (shows installed services and their status)

Based on the details you have provided I assume that there is some mixup with the PHP packages, and this should help you to get rid of the problem. Please note, that the following command will most likely influence other website on the same server, and you should understand what this command does before you run it. In essence it will remove all php packages you have right now, and then install back only php7.0 packages.

apt update

apt purge --auto-remove php-common php-fpm php-mysql php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-mysql php7.0-opcache  php7.0-readline

apt autoremove -y
apt autoclean -y

apt install php7.0-fpm php7.0-mbstring php7.0-xml php7.0-mysql php7.0-common php7.0-gd php7.0-json php7.0-cli php7.0-curl 
Cninroh
  • 1,796
  • 2
  • 21
  • 37
  • Hi, installed packages; php-common install php-fpm install php-mysql install php7.0-cli install php7.0-common install php7.0-fpm install php7.0-json install php7.0-mysql install php7.0-opcache install php7.0-readline install – Mr.Ayanlar Sep 23 '16 at 14:46
  • I updated answer based on your input, but I still need to know which Ubuntu version you run.. and which services you have installed / run.. – Cninroh Sep 23 '16 at 14:58
  • thank you everybody, my issue resolved. I updated to last version my wordpress site before moving site. :) – Mr.Ayanlar Sep 26 '16 at 06:03