Compiling PHP 5 in Mac OS Leopard and default Apache

It's been a long time since my last post in this blog. I've been working hard in both the CAMPUS Project (An MIT OKI web services layer form the UOC) and also in my next entrepreneur project based on web semantics.

For this my own project, I've been dealing with C++, python, postgreSQL, the Django Project (thanks Chuck!) and also TurboGears. When almost everything was correctly configured and running, I realized that the PHP distribution that comes within Mac OS Leopad did not include the postgreSQL connector.

I do not know the reason for this, as the connector for MySQL is correctly installed by default, but I had to solve that problem and I started querying google form some information. If you spend a couple of minutes in doing this, you'll find many solutions (like this) that include installing a new Apache in your Mac. But you know that your Leopard comes with a Apache web server, so why do you need to install another one? (MAMP is always a good and easier option, anyway!)

Reading the docs on Apache, I finally managed to find out the correct configuration line for compiling PHP from source and upgrading your Apache server with it.

Once you've downloaded the PHP code from, all you have to do is type this command:
sudo ./configure --prefix=/usr/bin --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/private/etc --with-zlib --with-zlib-dir=/usr --with-openssl --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-sockets --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/sbin/apxs --with-pgsql --with-ldap=/usr --with-kerberos=/usr --enable-cli --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-sockets --with-iodbc=/usr --with-curl=/usr --with-config-file-path=/etc

Note that /usr/local/mysql is the path for MY installation of MySQL. Yours can differ!

Those are all the configuration params to compile correctly a new distribution of PHP5.X and "install it inside" the Apache embedded in you Mac OS.

After doing that, you'll only have to run:
sudo make
sudo make install

and restart yout apache server (you can do that from System Preferences->Share if you had enough Terminal for one day :). Try out your new installation by creating and running a script called phpinfo.php in your /Library/WebServer/Documents directory. This file must contain (between the php tags):


Now, if you start connecting with mySQL or postgreSQL! Enjoy!

(Queda para mañana la versión en castellano. Si es que tengo ganas, claro XD)

Popular posts from this blog

Diseño y comités

Creating an e-commerce platform with Couchbase 2.0

Revisiting charts: NodeJS, Twitter and Elasticsearch