How do I move the Library/WebServer/Documents folder, which contains files shown by http://localhost ? For instance, to the Desktop. Also, can the ~/Sites folder be moved too?
So the short answer with reply is, "Sure, but WHY?!?"
The WebServer for Mac OS X (I'm assuming 10.6 Snow Leopard Client for the details of the answer) is based entirely on Apache. There are tonnes of web resources for Apache.
The key to Apple's Web Services are in /etc/apache2
You can (with admin privs) modify the httpd.conf (again; loads of web refs on this file) specifically pointing DocumentRoot anywhere.
However; and this is the list of caveats of why this is a weird thing to do...
- You have to be sure that the web process has the proper privs to read the directory in the location you may move it.
- You run the risk of something getting access to other files around the moved location
- This is non-standard configuration in the OS and is likely to break in a future verison
- The location is non-user volatile; meaning that deleting a user won't accidentally delete the served root folder. (Apache will fail to launch) if it can't find a served root folder
On top of this; we talk about moving the ~Sites. When you generate a new user acct; the OS generates a virtual directory conf in the /etc/apache2/users directory. Apache is smart enough to expand the ~ into a user name. All the above Caveats hold.
The question is why do you want the root folder on your desktop? It would seem to be more convenient to do one or more of the following:
- make an alias of /Library/WebServer/Documents on your desktop
- Setup groups/acls on /Library/WebServer/Documents to assure the correct write access
Without knowing why you're motivated to do this; I can't really hazard any other suggestions.
If it's a question of moving your web services directory to a network share... Now your solution is more along the lines of OS X Server (10.6) or doing your own apache install.
You have to be sure that the web process has the proper privs to read the directory in the location you may move it.