Setup Apache on Mac OSX Leopard

I’ve had my Macbook for a little over a year now. However, I just recently found out Leopard comes with apache (apache2 to be specific) already installed. To verify this is true, open up Terminal and type

>> apachectl -V
Server version: Apache/2.2.9 (Unix)
Server built:   Sep 19 2008 10:58:54
Server's Module Magic Number: 20051115:15
Server loaded:  APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D HTTPD_ROOT="/usr"
 -D SUEXEC_BIN="/usr/bin/suexec"
 -D DEFAULT_PIDLOG="/private/var/run/"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/private/var/run/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"

To start up apache, you can do it a couple of ways.

Type sudo apachectl -k start



  1. Go to System Preferences
  2. Click on Sharing
  3. Check the box that says Web Sharing

You can go to http://localhost or the URL provided in the Web Sharing screen to confirm apache is running and is able to serve up requests.

There is also a ~/Sites directory in your home folder. Apache is already setup to serve up files from this directory under http://localhost/~[username] where [username] is your user account name. Any files here will be render for example ~/Sites/index.html is accessible from the browser via http://localhost/~[username]/index.html.

One note to get this to work. Out of the box, all requests to /Sites result in a Forbidden 403 error. To resolve this issue, modify the conf file specified above as SERVER_CONFIG_FILE (/private/etc/apache2/httpd.conf in my case) from

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all


<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all

Restart apache (sudo apachectl -k restart) and try going to http://localhost/~[username] again.

Setup Apache on Mac OSX Leopard

12 thoughts on “Setup Apache on Mac OSX Leopard

    1. I was working with raw HTML and javascript just by itself. Not in a rails or java app. When working off the filesystem, local file references don’t 404 in firebug and there are some other oddities that seem to happen. For example, code that keys off of http or https doesn’t work because the protocol is file://

  1. williebillie12 says:

    Thank you. After upgrading my HDD and copying over my previous img my ‘localhost’ ceased to resolve correctly. Your final tip solved all my issues. Thank you so much.

  2. Laura says:

    hallo, I’m really new with php and I’m trying to setup Apache on my mac, in order to create some test files. I had troubles in seeing a seample file I created in html on my browser and I really don’t understand what’s the matter: I create the file .html and put it into Sites folder, but when I try to open it seems not to find it! Text precisely says: Error 404 – The requested URL /~myusername/file_name.html was not found on this server.
    Web sharing is active and when I test index.htm into Sites folder, as well, with http://localhost/. it works. So, what could be my problem? I’m using OS Snow Leopard. Thank you for any suggestion.

Leave a Reply

Your email address will not be published. Required fields are marked *