Local Web Development With OS X 10.5 (Leopard)

With the release of Leopard last Friday, it appears the bulk of my previous tutorials are now taken care of out of the box. mod_rewrite is enabled by default, and a decent (but not robust) installation of PHP 5.2.4 is ready to go – it only needs to be uncommented in the Apache configuration file.

The PHP installation is missing some key extensions, like PostgreSQL support and the GD library to name a few. But the majority of commonly used extensions are ready to go. Marc Liyanage is already on the case and working out the kinks for his own installer including those additions. The only thing missing at this point is MySQL support for Leopard. As of this writing, there is no installer available yet.

The rest of this post assumes you are working from a clean install or an “archive and install” of 10.5. I’m not sure what the Apache configuration files may look like if you simply upgraded from 10.4 or 10.3 – if they are clean this should work just fine.

Open the Apache configuration file (I’m using TextMate, which is where the ‘mate’ command comes from):
$ mate /etc/apache2/httpd.conf
and scroll to line 114 – it should look like this:
#LoadModule php5_module libexec/apache2/libphp5.so
Just remove the comment:
LoadModule php5_module libexec/apache2/libphp5.so

To enable Virtual Hosts, uncomment line 461:
Include /private/etc/apache2/extra/httpd-vhosts.conf
and add your own directories in your /etc/apache2/users/you.conf file. Similar to the 10.4 configuration, change the first two lines (inside ) like so:
Options All
AllowOverride All

and add your Virtual Host directives after that:

DocumentRoot /Users/yourname/Sites
ServerName localhost

DocumentRoot /Users/yourname/Sites/devsite
ServerName devsite

Restart Apache:
$ sudo apachectl restart
and you’re all set.

The only thing left to do is update your hosts file:
$ mate /etc/hosts
and add whatever you used for your ServerName after the other entries: devsite


Now I need to figure out if those rumors of Ruby on Rails out of the box are true…

  1. Dear Michael,
    I updated to Leopard but when i try to access my personal site on the Ma at:

    I receive this error:
    You don’t have the permissione to access /~luigi/ n this server

    Do you have an idea about it ?

  2. Hi Luigi,

    There are two things you can try:

    1) If you copied the files over from a previous install, check the permissions and the user:group to make sure it’s correct. From the command line:
    $ cd ~/Sites
    $ ls -al
    if the user:group in the listing looks something like this:
    luigi 501
    you’ll need to fix the group (501 is a uid and may not match up with any user groups on your new install). While in your Sites directory (very important!), use this command:
    $ chown luigi:staff *
    which should set the permissions correctly (on my install, anything that was in the web root from the install was set to the group ‘staff’).

    2) The other item that may be causing the issue is how you have the <Directory "/Users/luigi/Sites"> setting (in your /etc/apache2/users/luigi.conf file) configured. Make sure the next two lines look like this:
    Options All
    AllowOverride All

    without Options All I got the same error.

    Let me know if that helps…

  3. Thanks Michael,
    unfortunately it does not work.

    listing the files did not gave me the permission setting like you wrote (501…)
    but the home was listes as drwxr-xr-x+

    I did the chown anyway but there was no effect.

    I tried also the second solution but there was no file in the dir:

    What about it ?

  4. Also noticing now that the .conf file is in:


    Opened it and it was:

    Options All
    AllowOverride All
    Order allow, deny
    Allow from all

  5. Luigi – see if you can search for “/etc/httpd/users” in your Apache configuration file. If no results come up, that file is most likely ignored and is a result of your old 10.4 install. Try copying the luigi.conf (or whatever your username is) file to the /etc/apache2/users folder and restart Apache. It’s possible that file is just missing… I can’t imagine the /etc/httpd folder is used for anything anymore on 10.5 (it doesn’t even exist on a clean install of Leopard)

  6. Thanks Michael, I moved that file and
    now It works … I have access to that directory.

    Anyway when I try to see my wordress sites….I oy receive a directory listing.
    Maybe because it can not recognize the PHP files ?
    (I see a “?” next to PHP and xml files…)

    Don’ t remember where to set this option….

  7. Luigi – if you call the index.php file directly, does it work? If not, make sure you uncommented the line to enable php as described in the post. If it does, you probably just need to update the DirectoryIndex setting – this tells Apache which file to show first, and if it’s not available, which one to show next. Around line 224 of your Apache configuration you should see this line:
    DirectoryIndex index.html
    change it to this:
    DirectoryIndex index.php index.html

  8. Dear Michael,
    now it works….

    I opened the http.conf of my new apache2 dir with textmate
    and uncommented the php5_module line.

    It seems that Leopard uses actively PHP5 and does not recognize my PHP4 Tiger install.


    • Richard
    • November 22nd, 2007

    One thing I’ve noticed is that Leopard was weird with permissions in general, Apache runs off the www user and www does not have permission to access the user directories. I had to use dseditgroup and add www to my user’s group (GID 501), and my problem was immediately resolved!

  9. Hey, great article. Though, when I set up my Virtual Hosts, it always takes me to the main directory (my Users/me/Sites/ instead of Users/me/Sites/phpMyAdmin/)

    Any ideas why?

  10. Hi Jake,

    Check the order of your virtual hosts in your users.conf file. Make sure the first one is for localhost (pointing to your /Users/me/Sites directory) and add all other virtual hosts after that.

    Also, if this is a clean install of Leopard, make sure you uncommented NameVirtualHost *:80 in /etc/apache2/extra/httpd-vhosts.conf. I need to re-write this tutorial from scratch including all steps instead of relying on the old post with updates for Leopard. I’ll let you know when that’s available!


    • Richard Connor
    • March 5th, 2008

    Found this problem occurring in a clean system installed on my MacBook Air (nice machine, btw – better than the reviews make out!)

    The problem as pointed out by Richard above is with permissions: the Users/richard directory was set at drwx——; having messed about for most of the day trying to fix the 403 problem via the config files all I had to do was to chmod to drwxr-xr-x and it works!

    But a spooky thing; while http://localhost/~richard/ gave a 403 error, http://localhost/ worked OK and served the standard Apache welcome page – even although this is apparently set to the Users/richard/Library/WebServer/Documents directory (and Library has defaut rx permission only for user.) I had noticed that it wasn’t coming from there – in fact, this directory wasn’t even initialised. What is going on?!

    Finally I must say I’m a bit disappointed; after ten years of absence from the Mac world one of the reasons I changed back is that they are supposed to work! So maybe not many people will be running Apache on the MacBook Air, but how can they get this so wrong?

    Thanks anyway everyone, a really good, informative and informed thread!

  11. Richard,

    It looks like you’ve got an error in the directory you’re looking for. It should have been /Users/richard/Sites. It seems you may be getting that mixed up with /Library/WebServer/Documents, which is the default – but is not in your user directory – it’s in the /Library directory at the root of the drive.

    It’s possible http://localhost/ is still serving /Library/WebServer/Documents/index.html.en (the last two letters will change if your language is set to something other than English – or blow away all the files in that directory and simply use index.html). Modify that page to be sure – if you don’t see the changes on refresh, it’s being served from somewhere else.

    As for the 403 error, it’s likely caused by permissions, but everything in your /Users/richard/Sites directory should be readable by Apache. Hopefully some of the other comments on this post will help – otherwise post again and I’ll see if I can help.

    And thanks for the kind words!

    • Michael Boudreau
    • June 20th, 2008

    I had the same symptom Luigi reports (trying to access gave me the 403 error) and could not find anything wrong with the directory and file permissions in ~/Sites.

    Finally I found that /private/etc/apache2/httpd.conf sets the default access to “deny from all”. I created the file /private/etc/apache2/users/michael.conf with

    Order allow,deny
    Allow from all

    and then I was able to view the pages in my Sites folder.

    • harley1387
    • August 7th, 2008

    Here’s the fix from Apple — worked as expected:


    • Ray-Ray
    • October 29th, 2008

    Thanks harley1387! Followed the link to the Apple site, worked like a charm!