Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I setup a localhost using the "Sites" folder on my Mac?

share|improve this question

Open System Preferences » Sharing, and enable Web Sharing.

On Mountain Lion Web Sharing has been removed from preferences, so use sudo apachectl start to start Apache.

You'll find the URLs specified there. For example, my Sites folder /Users/danielbeck/Sites is accessible as

share|improve this answer
Thank you, but I wanted to get local php working such as WordPress. I have seen many posts, but none about the "Sites" folder. – david Dec 24 '10 at 0:41
@david In that case, your question is lacking your actual requirements. You need to configure Apache to support PHP, just as on any other system. httpd.conf is in /etc/apache2, and while it's been a while since I worked with it, you might have success by uncommenting the line containing php5_module, and toggling Web Sharing to restart Apache. – Daniel Beck Dec 24 '10 at 0:44

The web sharing checkbox was removed in 10.8, but sudo apachectl start also enbales the launchd agent permanently (see cat /usr/sbin/apachectl). To make http://localhost/~username/ work, you can save something like this as /etc/apache2/users/username.conf:

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

If you want to direct localhost to ~/Sites/, you can change DocumentRoot in /etc/apache2/httpd.conf.

You can add a virtual host by uncommenting Include /private/etc/apache2/extra/httpd-vhosts.conf in /etc/apache2/httpd.conf, adding to /etc/hosts, and adding this to /etc/apache2/extra/httpd-vhosts.conf:

<VirtualHost *:80>
    DocumentRoot "/Users/username/Sites/testsite/"

sudo apachectl restart applies changes.

share|improve this answer
I wonder, is it possible to change location for this folder /Users/username/Sites/ to new one? for example /Users/username/PHP/ – Aleks Dorohovich Aug 10 '15 at 13:42

Here's a link to a great Step by step guide, on how to setup Apache, PHP and MySQL locally using the Sites folder.

It's geared towards Mountain Lion (10.8) but I'm sure it's adaptable to your needs.

share|improve this answer
please do no use links as answers, it is strongly disencouraged. if the link gets broken, so does your whole answer. instead, try elaborating a consistent answer with relevant data from the link and post the same link as reference. – Lorenzo Von Matterhorn Mar 14 '13 at 3:08
And now the link is dead :( – DelightedD0D Jul 29 '15 at 11:40
New link… – DelightedD0D Jul 29 '15 at 11:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .