I am trying to setup webserver with PHP 7 RC3 + Nginx on Ubuntu 14.04 (for test purposes).

I installed Ubuntu in Vagrant using ubuntu/trusty64 and PHP 7 RC 3 from Ondřej Surý (https://launchpad.net/~ondrej/+archive/ubuntu/php-7.0).

I can not find the way to install MySQL PDO (PHP sees PDO class but not anything related to MySQL, like PDO::MYSQL_ATTR_DIRECT_QUERY etc.)

Looks like there is no lib php7.0-mysql (by analogy with standard php5-mysqlnd and php7.0-fpm etc. from Ondřej)

Section PDO in phpinfo():

PDO support      enabled
PDO drivers      no value

How can I get it?

share|improve this question
2  
You say Ubuntu 12.04, but then that you're using ubuntu/trusty64 which is 14.04. Assuming that you are in fact using Trusty (after all, Ondřej hasn't produced packages for Precise) then his php-modules package will provide php-mysql. – eggyal Sep 23 '15 at 0:00
    
Yes, you are absolutely right! (version is fixed). And your suggestion with module name works. Thanks! If you add it as answer I will mark it as correct. – SmxCde Sep 23 '15 at 0:08
    
My mistake - i was searching like this apt-cache search php pdo and module php-mysql in this case is not shown. – SmxCde Sep 23 '15 at 0:13
    
If it's anything like standard Ubuntu/Debian you can also install php5-mysqlnd to use the mysql native driver, which according to that link is "strongly encouraged", even if the Ubuntu devs don't use it by default. – Mike Sep 23 '15 at 1:10
1  
Mike, php5-mysqlnd does not work for me cause I install PHP 7. – Pavel Sep 23 '15 at 3:28

For thoses running Linux with apache2 you need to install php-mysql

apt-get install php-mysql

or if you are running ubuntu 16.04 or higher just running the following command will be enought, no need to edit your php.ini file

apt-get install php7.0-mysql

If you are running ubuntu 15.10 or below:

Edit your php.ini file and search for pdo_mysql you might found something like this

;extension=php_pdo_mysql.so

Change it to this

extension=pdo_mysql.so

Save the file and restart apache

service apache2 restart

Check that it's available in your phpinfo()

share|improve this answer
1  
Just a general FYI, I would highly recommend using MySQLND(php-mysqlnd) instead of the older php-mysql package – Machavity Sep 23 '16 at 13:06
    
Not everyone has the luxury of choosing what library the customer app is already using, and not everyone can just "apt-get" – dagelf Mar 1 '17 at 7:12
    
Note: "service restart apache2" should read "service apache2 restart". For Ubuntu 16.04 I used only "sudo apt-get install php7.0-mysql" and "sudo service apache2 restart". – Anthony Scaife Oct 1 '17 at 20:13

First install php-mysql

sudo apt-get install php7.0-mysql

then enable the module

sudo phpenmod pdo_mysql

and restart apache

sudo service apache2 restart 
share|improve this answer
up vote 3 down vote accepted

Since eggyal didn't provided his comment as answer after he gave right advice in a comment - i am posting it here: In my case I had to install module php-mysql. See comments under the question for details.

share|improve this answer

First, check if your php.ini has the extension enabled "php_pdo_mysql" and "php_mysqli" and the path of "extension_dir" is correct. If you need one of above configuration, then, you must restart the php-fpm to apply the changes.

In my case (where i am using the Windows OS in the company, i really prefer OSX or Linux), i solved the problem putting this values in the php.ini:

; ...

extension_dir = "ext"

; ... 

extension=php_mysqli.dll
extension=php_pdo_mysql.dll

; ...

I hope this helps.

share|improve this answer
    
This only helps if those files are actually present on the system in the first place. – dagelf Mar 1 '17 at 7:13

If you are on windows, and your php folder is not in your PATH, you have set the absolute directory in your php.ini

for example:

extension_dir = "C:/php7/ext"

and uncomment

extension=php_mysqli.dll
extension=php_pdo_mysql.dll

Restart apache2.4 and it should work.

I hope it helps.

share|improve this answer

I had, pretty much, the same problem. I was able to see that PDO was enabled but I had no available drivers (using PHP 7-RC4). I managed to resolve the issue by adding the php_pdo_mysql extension to those which were enabled.

Hope this helps!

share|improve this answer

Had the same issue, resolved by actually enabling the extension in the php.ini with the right file name. It was listed as php_pdo_mysql.so but the module name in /lib/php/modules was called just pdo_mysql.so

So just remove the "php_" prefix from the php.ini file and then restart the httpd service and it worked like a charm.

Please note that I'm using Arch and thus path names and services may be different depending on your distrubution.

share|improve this answer
  1. download the source code of php 7 and extract it.
  2. open your terminal
  3. swim to the ext/mysqli directory
  4. use commands:

    phpize

    ./configure

    make

    make install (as root)

  5. enable extension=mysqli.so in your php.ini file
  6. done!

This worked for me

share|improve this answer
    
Thanks, the same worked for pdo_mysql. Not sure why it isn't compiled as part of default make;make install o_O – dagelf Mar 1 '17 at 7:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.