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_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_FLOCK_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="/usr" -D SUEXEC_BIN="/usr/bin/suexec" -D DEFAULT_PIDLOG="/private/var/run/httpd.pid" -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.
sudo apachectl -k start
- Go to System Preferences
- Click on Sharing
- 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
/private/etc/apache2/httpd.conf in my case) from
<Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory>
<Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Allow from all </Directory>
Restart apache (sudo apachectl -k restart) and try going to
12 thoughts on “Setup Apache on Mac OSX Leopard”
So what are you doing with Apache locally, or was this posted out of sheer boredom?
Very good doc – Objective, easy to understand.
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.
how do you make apache non-local?
Thank you…. this was helpful and got me over that annoying 403 error..!
hi, i tried your tips but i still get the “Forbidden
You don’t have permission to access /~user/ on this server.” message.. any ideas?
Can I use this to tunnel through the Chinese Firewall? If so do I need to set up another server outside China?
thanks, it worked
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 http://127.0.0.1/~myusername/file_name.html 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.
[…] how to setup apache on my mac Share this:FacebookTwitterTumblrEmailLike this:LikeBe the first to like this post. […]