How do I figure out which ./configure options to use when building PHP 5.3.0 on Mac OS X? There are 10 zillion options and I have no idea which ones to use.

All I want is to make sure that I have PDO and PDO+MySQL enabled.


[[[[scream!]]]] I ran sudo port install php5-mysql and it "worked", but when I run php:

$ php
PHP Warning:  Cannot load module 'mysql' because required module 'mysqlnd' is not loaded in Unknown on line 0

Warning: Cannot load module 'mysql' because required module 'mysqlnd' is not loaded in Unknown on line 0
dyld: lazy symbol binding failed: Symbol not found: __mysqlnd_palloc_rinit
  Referenced from: /opt/local/lib/php/extensions/no-debug-non-zts-20090626/mysqli.so
  Expected in: dynamic lookup

dyld: Symbol not found: __mysqlnd_palloc_rinit
  Referenced from: /opt/local/lib/php/extensions/no-debug-non-zts-20090626/mysqli.so
  Expected in: dynamic lookup

Trace/BPT trap


aha! The maintainer of macports found the same problem. I did sudo port selfupdate and reran the install of php5 and it worked fine.

link|improve this question

72% accept rate
You might consider accepting an answer (it'll help your acceptance rate and give points to whomever you choose). – Nerdling Sep 13 '09 at 2:16
thanks but not till I actually get something working. – Jason S Oct 17 '09 at 14:26
feedback

4 Answers

up vote 3 down vote accepted

Use MacPorts as they have packaged together most of the settings in a way much easier to understand. For example:

port install php5-mysql

link|improve this answer
aha, that's the kind of approach I think I'd like. Do they document which configure options they use and why? – Jason S Aug 26 '09 at 13:12
You can view the configuration flags as they're run port -d ... or [view the portfiles][1]. [1] trac.macports.org/browser/trunk/dports/php/php5-mysql/Portfile – Nerdling Aug 26 '09 at 13:41
feedback

Enable the options you want by specifying them on the configure command line. The MySQL options that appear in my 5.1.6 configure command are as follows:

$ ./configure --help | grep mysql
  --with-mysql[=DIR]      Include MySQL support. DIR is the MySQL base directory
  --with-mysql-sock[=DIR]   MySQL: Location of the MySQL unix socket pointer.
  --with-mysqli[=FILE]    Include MySQLi support. FILE is the optional pathname 
                          to mysql_config
  --enable-embedded-mysqli  MYSQLi: Enable embedded support
  --with-pdo-mysql[=DIR]    PDO: MySQL support. DIR is the MySQL base directory

At a minimum, I would specify an install prefix along with the type (v1 or v2) of Apache install (which you should have already built) you have:

$ ./configure --prefix=/opt/apache --with-apxs2=/opt/apache/bin/apxs \
--with-mysql --with-pdo-mysql

Ensure that mysql_config (assuming there is such a thing) is in your path, or tell configure where the mysql libraries are located.

link|improve this answer
feedback

How do I figure out which ./configure options to use when building PHP 5.3.0 on OSX?

If you want some really generic advice for building packages when you need to know how to configure something.

  • Read the Fine Manual, usually the docs will give examples telling you what you need, and what option does what. Read the file named INSTALL, check the web site. For a package as popular as PHP the information should be pretty easy to find.
  • PHP 5.3.0 is a pretty new package, but there are older packages available. Go find a package someone else built and copy the configuration line they used.
link|improve this answer
feedback

For PHP 5.3, integrating MySQL access libraries is really easy. It's just a matter of enabling the MySQL Native Driver (or mysqlnd) in the configure flags:

./configure --enable-pdo --with-mysql=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd

For what it's worth, take a look at buildphp, which is a Rake-based build system for PHP that was made specifically to make compiling PHP 5.3 (and an up-to-date set of libraries for PHP extensions) easy.

http://github.com/patcoll/buildphp

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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