HTML and CSS Reference
the Finder (once you're in the Finder, the Command+Shift+H keyboard shortcut will take
you directly to your Home folder) and create a new folder called Sites. This is where you'll
create your web files.
The editing of the httpd-userdir.conf file isn't necessary on OS X prior to Mountain Lion.
Now upon restarting Apache (with the apachectl graceful command), Apache will
immediately recognize your folder, but if you try to access it through a web browser, you'll
get an error. The reason for this is Apache has very restrictive default directory settings as
a security precaution. To override this for user directories you need to edit the httpd-user-
dir.conf file. To open the file for editing, use this command:
$ sudo nano /etc/apache2/extra/httpd-userdir.conf
You may or may not be prompted for your password depending on when you last used
Once the httpd.userdir.conf file is open, scroll to the bottom and add the following:
Options Indexes FollowSymLinks MultiViews
Allow from all
Exit nano as you did before saving the revised httpd.userdir.conf file.
In short, this bit of code tells Apache that it has permission to look and serve content from
any user's Sites folder.
To test everything and make sure it all works, type the following at the terminal prompt:
$ echo "<? phpinfo() ?>" > ~/Sites/test.php
$ sudo apachectl graceful