Installing Apache 2 and PHP 5 on OS X

February 26th, 2004

I started out tonight to install a parallel Apache2 (2.0.48) and PHP5 (5.0.0b4) on the laptop, to complement the existing Apache/PHP4 install. And I thought I would keep notes as I did it, maybe turn it into an extended blog entry, “Man Conquerors Technology” and all that, you know the type. Who knows, if it really got hairy, maybe I could make into an article for O’reilly. My scholarly ambitions were foiled once again; the software was just too damn easy to install

Build Apache2

> ./configure --enable-mods-shared=ALL
> make
> make install

Then tweak the conf file a bit. UserDirs should be set to Sites for example. Probably want to set User/Group to www/www. Also note that Port has been totally superceeded by Listen.

Build PHP5

> apt-get install libxml2
> ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-libxml-dir=/sw --prefix=/usr/local/php5
> make
> make install

I first had to upgrade my libxml2, which Fink did smoothly. Then configure wasn’t looking in /sw for my libraries, and rather then figure out why I told it explicitly where to find libxml. I installed into the prefix /usr/local/php5 in order not to step on the toes of my PHP4 install. This is especially useful as I’m finding a number of PEAR module need to be patched to run under PHP5, so I need separate PEAR directories for v4 and v5

So now I’ve got Apache/1.3.29 PHP/4.3.4 (entropy) responding on port 80, and Apache/2.0.48 PHP/5.0.0b4 responding on port 81.

Oh, and Magpie works just fine under PHP5.

3 responses to “Installing Apache 2 and PHP 5 on OS X”

  1. Neil says:

    Great instructions! Short and it worked for me first time.

  2. Justin says:

    Hey, I’ve installed php5 on my OS X, running apache and it works great for file with the .php extension. However, I want to process .htm though php but I can’t seem to find out how to do it. I added this to the httpd.conf with no luck. If you have any idea what else I could try that would be great!

    # If php is turned on, we repsect .php and .phps files. AddType application/x-httpd-php .php .htm AddType application/x-httpd-php-source .htm .phps

    # Since most users will want index.php to work we
    # also automatically enable index.php
    <IfModule mod_dir.c>
        DirectoryIndex index.php index.htm index.html
    </IfModule>
    

  3. stever says:

    makes and installs of apache 2.2.6 and php 5.2.2 went fine.

    Apache’s index.html displays OK.

    Created test.php with contents in /usr/local/apache2/htdocs and it displays the text in the file. I don’t get the phpinfo output.

    Why?

    httpd.conf has “LoadModule php5_module modules/libphp5.so” in it and uncommented.

    Ideas?