Home » Questions » Computers [ Ask a new question ]

Map "Sites" folder to http://localhost on OS X

Map "Sites" folder to http://localhost on OS X

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

Asked by: Guest | Views: 266
Total answers/comments: 3
Guest [Entry]

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

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

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

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

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>"
Guest [Entry]

"I also wanted to move the local host files to an external hard drive.

The issue I had was spaces in the hard drive name or folder name. No matter what I added +Space it would not work. It did however work when I changed the hard drive and folder name removing the space(s) and then mapping it something like:

DocumentRoot ""/Volumes/HDD_NAME/WebServer/Folder_Name""

So now Dreamweaver or other edit is mapped to the external hard drive and the http.conf file is mapped to the external hard drive saving 100GB of my small internal hard drive's space. Of course, this means I can only edit and test locally with that external hard drive attached."