PHP Compiled From Source Mac OS X Leopard 1

Posted by Ben Reubenstein Sun, 13 Apr 2008 21:06:00 GMT

After getting passenger up and running I realized that I didn't have PHP cranking with the freshly compiled Apache. Here are the steps I took to get PHP going:

  1. Compile PHP from source, be sure to check out ./configure --help for more compile options. Also as always adjust to your systems paths as necessary.

    tar -zxvf php-5.2.5.tar.gz
    cd php-5.2.5
    ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-curl
    sudo make install
  2. I am not sure why but the php bin file ends up being called php.dSYM. There might be a compile option I missed to fix this or it could be the Mac OS X compiler. I fixed the issue by creating a symlink.

    sudo ln -s /usr/local/php/bin/php.dSYM /usr/local/php/bin/php
  3. Add /usr/local/php/bin to your path in .bash_login and reload your terminal so that it is in your path. You can confirm that you are getting the right php by issuing:

    which php
    #The command should return:
  4. Add directives to the httpd.conf for Apache to find the PHP module and handle .php files

    LoadModule php5_module        modules/
    AddHandler php5-script php
  5. Restart Apache

    /usr/local/apache2/bin/apachectl restart
  6. Put a file in the root of your server or in virtual host directory called info.php with the phpinfo command. Visit the file via your web browser to confirm your install.

    <?php phpinfo() ?>

Be sure to leave comments with any issues you have, or updates I can make to this document.