I'm running OS X 10.5; it looks like it came with Apache and PHP installed (minus some minor configurations which I turned on per this page; I've used Apache before so I know the basics of how httpd.conf works).
I've got a pre-existing script which uses PDO. I've got a MySQL database and can easily configure my script to access the database via PDO MySQL or PDO ODBC. The problem is, that even though I enabled the PDO MySQL and PDO ODBC extensions in php.ini, phpinfo() reports the only PDO drivers are sqlite2 and sqlite. I'm guessing the relevant extension .dll or .so files are not present? How do I get them?
note: I'm using the built-in install for PHP. (see apple's page on enabling php, which doesn't say anything about configure or adding additional .so files)
The default PHP install is not very useful. The easiest way to get more feature-complete versions of standard unix packages for OSX is to use either MacPorts or Fink. I personally prefer MacPorts, although I think most folks prefer Fink.
In OSX 10.7 and 10.8 the PDO drivers for MySQL are available by default. However, you may need to make other changes as explained in this post.
You need to run configure with argument:
/sw
if you use Fink. If you don't, change this to path where yourinclude/mysql.h
andlib/libmysqlclient.la
are (locate mysql.h
will help).If you just want to add PDO extension to existing installation, then download PHP source, go to
ext/pdo
directory, run:This will create and install appropriate
.so
file for you. Script will tell you where it put it. Sometimes it gets directory wrong, so ensure that it matchesextension_dir
in yourphp.ini
.If the
pdo_sqlite
extension is already working, you don't need to re-install thepdo
extension itself -- just thepdo_mysql
extension.Download the source code for the same version of PHP as is built-in, and:
Should be that easy.