---
title: 'Installing PHP 5.2.8 on OSX Leopard 10.5.6'
url: 'https://maxwesten.nl/blog/articles/installing-php-on-osx-leopard'
markdown: 'https://maxwesten.nl/blog/articles/installing-php-on-osx-leopard.md'
date: '2008-12-29'
description: "Because I travel a lot by train, it's easy to have a local development environment with me. Because OSX Leopard contains Apache2 and PHP 5.2.6, I installed MySQL, ZF, PEAR, setup the vhost conf for apache and added the path to the ZF and PEAR libraries to /etc/php.ini. This seemed to work fine for a day or two, but after that I needed to use the PDO_MySQL library. This didn't really work... The fact is that PDO_SQLite and PDO_SQLite2 are compiled along the installed PHP library, but PDO_MySQL isn't... Big FAIL!. So, we'll have to setup a new PHP/Apache2 combo..... Okay let's st"
taxonomy:
  category:
    - PHP
    - Work
  tag:
    - Apache
    - Hack
    - OSX
    - PHP
  archives_month:
    - dec_2008
  archives_year:
    - '2008'
---

# Installing PHP 5.2.8 on OSX Leopard 10.5.6

[Home](https://maxwesten.nl/)  [Blog](https://maxwesten.nl/blog)  [Articles](https://maxwesten.nl/blog/articles)  Installing PHP 5.2.8 on OSX Leopard 10.5.6 

## [ Installing PHP 5.2.8 on OSX Leopard 10.5.6](https://maxwesten.nl/blog/articles/installing-php-on-osx-leopard)

    29th Dec 2008   [Apache](https://maxwesten.nl/tag:Apache#body-wrapper) [Hack](https://maxwesten.nl/tag:Hack#body-wrapper) [OSX](https://maxwesten.nl/tag:OSX#body-wrapper) [PHP](https://maxwesten.nl/tag:PHP#body-wrapper)  

Because I travel a lot by train, it's easy to have a local development environment with me. Because OSX Leopard contains Apache2 and PHP 5.2.6, I installed MySQL, ZF, PEAR, setup the vhost conf for apache and added the path to the ZF and PEAR libraries to /etc/php.ini. This seemed to work fine for a day or two, but after that I needed to use the PDO\_MySQL library. This didn't really work... The fact is that PDO\_SQLite and PDO\_SQLite2 are compiled along the installed PHP library, but PDO\_MySQL isn't... Big FAIL!.

So, we'll have to setup a new PHP/Apache2 combo.....

Okay let's start:

## 1. Install the Apple Developer tools

If you haven't done it already, install the Developer Tools(XCode 3) from the OSX DVD

## 2. Install and update MacPorts

If you haven't installed MacPorts on your system, do so by downloading it from the [MacPorts website](http://www.macports.org) and running the installer. Now open a terminal window and update MacPorts:

```
sudo port selfupdate
sudo port sync

```

## 3. Install apache2

Create the following directory and symlink for the correct use of MySQL (the install searches there for libraries):

```
sudo mkdir /usr/local/mysql/lib/mysql
sudo ln -sf /usr/local/mysql/lib/lib* /usr/local/mysql/lib/mysql/

```

Install Apache2:

```
sudo port install apache2

```

Let the apache2 process be autostarted by the system:

```
sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist

```

Move the old Apache stuff out of the way:

```
sudo mv /usr/sbin/apachectl /usr/sbin/apachectl-leopard
sudo ln -s /opt/local/apache2/bin/apachectl /usr/local/bin/apachectl

```

Copy the sample conf file and make it the default

```
sudo cp /opt/local/apache2/conf/httpd.conf.sample /opt/local/apache2/conf/httpd.conf

```

Now you can modify your apache settings to your liking, but remember to use only the ones in the **/opt/local/apache2/conf** directory; the old configs(*/etc/apache2/conf*) are not used anymore.

## 4. Install the additional stuff needed

Then make sure we have everything installed we want in there; I want: GD libraries, iconv, PDO\_MySQL, curl

```
sudo port install jpeg
sudo port install libpng
sudo port install freetype
sudo port install libmcrypt
sudo port install tidy
sudo port install libiconv

```

Rename the default iconv.h because it generates errors while compiling PHP

```
sudo mv /usr/include/iconv.h /usr/include/iconv.h.leo_orig
sudo ln -s /opt/local/include/iconv.h /usr/include/iconv.h

```

## 5. Download, configure and install PHP

Download the php5.2.8.tar.gz file from the [PHP website](http://www.php.net/downloads.php). go to your download directory and run

```
tar xvzf php-5.2.8.tar.gz 

```

Then move this folder to the /opt/local/php-5.2.8 folder

```
sudo mv php-5.2.8 /opt/local/

```

Then create a symlink that you can compile against:

```
sudo ln -s /opt/local/php-5.2.8 /opt/local/php

```

Go into the newly created 'folder':

```
cd /opt/local/php/

```

Now configure PHP:

```
'./configure' \
'--prefix=/opt/local/php' \
'--with-apxs2=/opt/local/apache2/bin/apxs' \
'--with-xsl=/usr' \
'--with-tidy=/opt/local' \
'--with-ldap=/usr' \
'--with-kerberos=/usr' \
'--enable-mbregex' \
'--enable-ftp' \
'--with-iodbc=/usr' \
'--with-curl=/usr' \
'--enable-mbstring' \
'--with-gd' \
'--with-jpeg-dir=/opt/local' \
'--with-png-dir=/opt/local' \
'--with-zlib-dir' \
'--enable-sockets' \
'--enable-exif' \
'--with-mcrypt=/opt/local' \
'--enable-soap' \
'--with-mysql=/usr/local/mysql' \
'--with-mysqli=/usr/local/mysql/bin/mysql_config' \
'--with-pdo-mysql=/usr/local/mysql/bin/mysql_config' \
'--with-mysql-sock=/tmp/mysql.sock' \
'--with-freetype-dir=/opt/local' \
'--with-openssl=/opt/local' \
'--with-iconv=/usr' \
'--with-libxml-dir=/usr' \
'--with-xmlrpc' \
'--enable-cli'

```

Then make and install php:

```
sudo make
sudo make install

```

And rename the old PHP and create a symlink to the new binary:

```
sudo mv /usr/bin/php /usr/bin/php-leopard
sudo ln -s /opt/local/php/bin/php /usr/bin/php

```

copy the new php.ini file and edit it to your liking:

```
sudo cp php.ini-dist lib/php.ini

```

**Note:** The new php.ini file in use is the one located at: **/opt/local/php/lib/php.ini**

## 6. Restart the webserver

Up until now the old webserver was running. Shut it down and then start the new apache2:

```
sudo apachectl-leopard stop
sudo apachectl start

```

If all went well, Apache is running and PHP scripts get executed. Please check the installed features by calling a page with the following code on it, to ensure everything is installed.

```

```

In the next post we will add xDebug to the stack and later on the debugging environment is setup for different IDEs.

[Part2: Installing xDebug on OSX](https://maxwesten.nl/blog/articles/installing-xdebug-204-or-21-on-osx)

 [ Previous Article](https://maxwesten.nl/blog/articles/themed-osx-terminal) [Next Article ](https://maxwesten.nl/blog/articles/installing-xdebug-204-or-21-on-osx)

#### Related Posts

- 100 

     [Easiest local development environment on OSX](https://maxwesten.nl/blog/articles/easiest-local-development-environment-on-osx "Easiest local development environment on OSX")
- 100 

     [Mod\_security settings for Wordpress 3.x](https://maxwesten.nl/blog/articles/mod_security-settings-for-wordpress-3-x "Mod_security settings for Wordpress 3.x")
- 100 

     [Developing in PHP with NetBeans 6.8](https://maxwesten.nl/blog/articles/developing-in-php-with-netbeans "Developing in PHP with NetBeans 6.8")
- 100 

     [Installing xDebug 2.0.4 or 2.1 on OSX](https://maxwesten.nl/blog/articles/installing-xdebug-204-or-21-on-osx "Installing xDebug 2.0.4 or 2.1 on OSX")
- 100 

     [CakePHP: Calling bake from every dev-app install folder](https://maxwesten.nl/blog/articles/cakephp-calling-bake-from-every-dev-app-install-folder "CakePHP: Calling bake from every dev-app install folder")

[←](https://xn--sr8hvo.ws/%F0%9F%92%95%F0%9F%8E%89%E2%A4%B5%EF%B8%8F/previous)An IndieWeb Webring 🕸💍 [→](https://xn--sr8hvo.ws/%F0%9F%92%95%F0%9F%8E%89%E2%A4%B5%EF%B8%8F/next)

---

## Navigation

- Parent: [Articles](https://maxwesten.nl/blog/articles.md)
- Previous: [Installing xDebug 2.0.4 or 2.1 on OSX](https://maxwesten.nl/blog/articles/installing-xdebug-204-or-21-on-osx.md)
- Next: [Themed Tab Terminal for OSX Leopard](https://maxwesten.nl/blog/articles/themed-osx-terminal.md)
