User Tools

Site Tools


PHP5 Development on OSX (Mountain Lion) w/XDebug

In my professional and personal projects, I often end up doing quite a bit of PHP5 and PostgreSQL work and generally do all of my work on a Ubuntu Linux workstation. In an effort to be more mobile with my development environment, I ended up installing Zend Community Server last year. Not that this is a poor setup, but I don't need nor want a full install including MySQL running all the time, so I uninstalled.

Good news! OSX Lion comes with Apache2 (2.2.22) and PHP 5.3.15

Getting the development environment running

  • Give the Sites folder permissions
    sudo chgrp -R _www Sites
  • Create the user configuration file
    sudo vi /etc/apache2/users/`whoami`.conf

    with content

    <Directory "/Users/USERNAME/Sites/">
         Options Indexes MultiViews FollowSymLinks
         AllowOverride All
         Order allow,deny
         Allow from all

Enable Apache and PHP5

  • Enable the “Web Sharing”
  • Enable PHP5 on Apache2
    sudo vi /etc/apache2/conf/httpd.conf

    Uncomment the following line by removing the #

    #LoadModule php5_module libexec/apache2/

    Set instances of

    AllowOverride none


    AllowOverride all

[Optional] Install PHP PEAR

  • Install PHP PEAR
    • Retrieve PHP PEAR installer script
      curl -O
    • Run the installer with elevated privileges
      sudo php go-pear.phar
      • You can install PEAR wherever you want, but I installed in /usr/share/pear by changing the “Installation base”
        1-11, 'all' or Enter to continue: 1
        (Use $prefix as a shortcut for '/Users/bytecompile/pear', etc.)
        Installation base ($prefix) [/Users/bytecompile/pear] : /usr/share/pear
      • Hit “Enter” to continue. It seems silly, but directory for your include_path is /usr/share/pear/share/pear
    • Add pear to your path
      sudo ln -s /usr/share/pear/bin/pear /usr/bin

[Optional] Modify the php.ini

  • php.ini - create and modify the default PHP configuration file
    sudo cp /etc/php.ini.default /etc/php.ini
  • Edit the php.ini file with
    sudo vi /etc/php.ini

    and modify the include_path

    ;include_path = ".:/php/includes"

    change to

    include_path = ".:/php/includes:/usr/share/pear/share/pear"
  • Required edit ( PHP Timezone list ):
    date.timezone = Europe/London
  • Some other options, based on your personal preference (find and update within /etc/php.ini):
    short_open_tag = On
    display_errors = On

Restart Apache

sudo apachectl restart

Enable XDebug

  • Edit the php configuration file
    sudo vi /etc/php.ini
  • Find (or add) the line containing xdebug and sure they are uncommented
  • Restart apache
    sudo apachectl restart

IDE Setup: NetBeans

Download NetBeans w/PHP support

TODO: show how to setup for xdebug

IDE Setup: Eclipse

TODO: show how to setup for xdebug

osx/development/php5.txt · Last modified: 2012.11.19 00:54 by bytecompile