2

I'm trying to run a Symfony 3 app with php 7 installed from source and I'm getting a Missing PDO driver exception. According to http://pecl.php.net/package/PDO_MYSQL the PDO_MYSQL extension is now part of PHP core.

Q1.a) If I have the PDO_MYSQL extension (which I must, since its core) does that mean that I also have the mysql pdo driver?

Q2.b) Is there further runtime configuration I have to do to make sure that the driver gets used?

I've tried adding

extension=php_pdo.so

extension=php_pdo_mysql.so

to my loaded php.ini file.

Q2.a) Are these the correct extension names? How could I find out?
Q2.b)Do I even have to provide extension references for core php elements?

Finally:

Q3. How can I check whether my PHP install included the mysql pdo driver and how do I make sure that it is being loaded at runtime?

Thanks for your input.

Edit 1: I'm running on Linux Mint.
Edit 2: Here are a couple more details on what I'm seeing on my end:

"On starting up the built in php server I get the following message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/php_pdo.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20151012/php_pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/php_pdo_mysql.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20151012/php_pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0"

This message suggests to me that either the extension references are incorrect or the extension does not exist. I used "dpkg -L php-mysql" and found that the package was installed in "/usr/share/doc/php-mysql" however, when I check in the php-mysql directory, all I see is a changelog and a copyright file (with hiddens shown). Is this the true install location of the package and, if so, should there be more in this directory?

6
  • Depending on the packager pdo_mysql might be an extra package. Like it's the case of dotdeb's jessie packages. Commented Aug 8, 2016 at 22:43
  • Look into phpinfo and look for PDO MySQL. <?php phpinfo(); Commented Aug 8, 2016 at 22:44
  • What does php -m or php -i | grep PDO say? Commented Aug 8, 2016 at 22:47
  • I forgot to mention, phpinfo() only shows the sqlite pdo driver as being enabled. I suspect this is because either a) the driver isn't enabled correctly in php.ini or b) it is not installed. How can I tell which of these is the case? Commented Aug 8, 2016 at 22:48
  • php -m: [PHP Modules] Core ctype date dom fileinfo filter hash iconv json libxml pcre PDO pdo_sqlite Phar posix Reflection session SimpleXML SPL sqlite3 standard tokenizer xml xmlreader xmlwriter php -i | grep PDO: PDO PDO support => enabled PDO drivers => sqlite PDO Driver for SQLite 3.x => enabled Commented Aug 8, 2016 at 22:54

1 Answer 1

5

.so implies you are on Linux - did you install PHP as a package. You probably need to install the pdo/mysql package - PHP libraries may be "core", but not necessarily in the main package (confusing, but it just means it's not PEAR delivered, really).

sudo apt-get install php5-mysql

Or, if you're running PHP7:

sudo apt-get install php-mysql

This should restart the apache automatically, but to be sure you could do:

sudo service apache2 restart

The package installer for php-mysql should have put the .so libraries in /usr/lib/php/yyyymmdd/ - if you had installed PHP as a package, it would be looking here.

However, since you installed from source, it seems that PHP is looking elsewhere for the libraries. You can create symlinks from /usr/local/lib/php/extensions/no-debug-non-zts-20151012/ to the package installed libraries.

Sign up to request clarification or add additional context in comments.

7 Comments

This is one of the solutions I tried before posting this question. I've tried it again to no effect. Is there something I need to do after installing this package to get it to work? dpkg command says that its successfully installed.
@allen You'll need to restart the webserver. If apache 2.4 on ubuntu, sudo service apache2 restart
Hi @JeffPuckettII. Good thought, but I've already done this. I'll be posting some more info on the main post shortly that will hopefully narrow down the list of possible causes.
hmm - sorry, I missed where you said you'd installed PHP7 from source... I can only assume that this means PHP is installed with different paths to what the normal package system does... is there a reason you haven't installed PHP7 as a package?
There wasn't much package support for php7 when I installed it, I know there are some now. How would I go about switching from my install from source to a package based install? Thanks for your help.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.