How to: Redirect Apache’s Default
public_html Folder to a Directory in Your Home Folder
Purpose: The default installation of Apache (from a Ubuntu-Server installation) sets the base directory for the web documents as
/var/www (on Ubuntu’s installation — this may be different if you are running Apache on another machine); this may not be where you want it, in the end, and certainly isn’t as easily accessible from a remote machine. One option is to change where it is Apache searches for its web documents folder in Apache’s configuration file; another way, which I chose, is to create a symbolic link in the default location’s place and have it point to a directory in my user’s home folder.
Benefit: I can login remotely with my user name (
henry) and have direct access to the web documents root folder. This makes it easy to use FTP or SSH or AFP to move files around and I don’t have to fool with user groups or permissions.
If you want to do this, login as the user you want to host the web pages and run the following from the terminal:
$ mkdir ~/www
$ sudo mv /var/www /var/www-backup
$ sudo ln -s /home/henry/www /var/www
This will create a
www folder in your user’s home directory, change the name of Apache’s default
www directory, and create a symbolic link in its place that points to the directory you recently created.
index.html file in your new
~/www directory and you are good to go!