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

I'm using the built-in server on my Mac.

The URL to my Sites folder is: http://localhost/~username/

with MAMP I had just http://localhost/.

Is there any way to get just http://localhost/ with the built-in server?

I have only one user account on my Mac.

share|improve this question
up vote 3 down vote accepted

You want to change the "DocumentRoot" setting in the file /etc/apache2/httpd.conf, and restart web sharing.

share|improve this answer

I have also just changed DocumentRoot in /etc/apache2/httpd.conf. But another option is to use vhosts:

  1. Uncomment Include /private/etc/apache2/extra/httpd-vhosts.conf in /etc/apache2/httpd.conf
  2. Add this to /etc/apache2/users/username.conf or /etc/apache2/extra/httpd-vhosts.conf:

    <VirtualHost *:80>
        DocumentRoot "/Users/username/Sites"
        ServerName localhost
    </VirtualHost>
    
  3. sudo apachectl restart

If you get an error like You don't have permission to access / on this server, try adding this to /etc/apache2/users/username.conf:

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

Go to /etc/apache2/httpd.conf

Find

DocumentRoot  "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">

Change it to:

DocumentRoot "/Users/bob/Sites"
<Directory "/Users/bob/Sites">

Where bob is your username. Now you can access localhost/mywebsite instead of localhost/~bob/mywebsite

You might need to restart apache sudo apachectl restart

share|improve this answer

You need to put your site in /Library/WebServer (not sure about WebServer part but it should be similar) and make sure permissions are correct.

share|improve this answer
    
I want to have the files in the Sites folder, can I create an hardlink/symlink or something? – Sindre Sorhus Sep 5 '09 at 17:13
    
Yes, you can. But do it in the Terminal, the Finder doesn't really create real hard/symlinks. – Christian Studer Sep 16 '09 at 11:43

The best way to do this, which I've already done is this terminal command (first delete, rename or move the Documents folder out of /Library/WebServer): ln -s ~/Sites/ /Library/WebServer/Documents.

share|improve this answer

You must log in to answer this question.

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