1
votes

I am trying to compile pdo.so and pdo_mysql.so to get pdo support on my PHP5 install. I tried the following :

./configure --prefix=/thedirectory --with-mysql --with-pdo-mysql --enable-pdo

Compilation is successful but the .so aren't generated. I am supposed to have/specify a mysql installation?

Is the pdo support supposed to be compiled within php core ? If I run a php -m I can see PDO and pdo_mysql registered, but a phpinfo() states no pdo_mysql support. I guess the php -m just tells me php has pdo support but still need the .so?

Could anyone advise?

Thanks

2
Which system do you use? PDO is included in the newest versions. Why do you compile it? - René Höhle
Your PHP CLI binary has PDO support compiled in. The PHP binary used by your web server does not. I think in order to generate the so files you will need to configure / make / make install - configure normally just generates a makefile, it doesn't actually compile it... How are you running PHP, against which web server? Apache/mod_php or CGI/FCGI? - DaveRandom
Thanks for the answers. I'm using a redhat 4 linux, I have been provided a compiled package of 5.2.17, but on which pdo_mysql doens't work as I get "Uncaught exception 'PDOException' with message 'could not find driver' " So i'm trying to add the support by putting the pdo.so and pdo_mysql.so in extensions folder and modify php.ini to use these extensions. I'm trying to compile from php-5.4.3 sources. Of course I ran make & make install and it was successful but as said, it doesn't generate the .so I am using PHP2.2 with mod_php5.so - lepolac
@lepolac If you get as far as a PDOException, you don't need to worry about pdo.so. If you're using redhat, can't you just get it with rpm? - DaveRandom
@DaveRandom oh yeah you are right, pdo is probably enabled then. In fact the phpinfo tells me pdo_sqlite is enabled, but not mysql. The easy rpm solution only exists in an ideal world which is not mine unfortunately :'(. Don't have access to it, and I'm building all this in custom locations anyway. - lepolac

2 Answers

1
votes

Use the following configure options:

./configure \
--with-mysqli=/home/user/programs/mysql/install/bin/mysql_config \
--with-pdo-mysql=/home/user/programs/mysql/install

The /home/user/programs/mysql/install directory is where MySQL has been installed.

You should see a pdo_mysql section in the phpinfo() output showing the following:

PDO Driver for MySQL    enabled
Client API version  5.7.16 
-3
votes

The latest versions of PHP come with PDO drivers for MySQL, Oracle, PgSQL, ODBC, SQLite and Firebird/Interbase. All you have to do is enable them in your php.ini:

;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll

Here I have MySQL, and PgSQL enabled while all others are disabled.

(This is from a php.ini file from Windows, but on linux it looks pretty much the same, just the extensions are in the form of pdo_mysql.so, pdo_pgsql.so, etc.)