Browsing the ‘ubuntu’ Category

Move apache’s localhost to home on ubuntu    September 24th, 2008 at 4:31 pm

I’ve only done this two other times and had to look for more than 2 minutes to find the answer so thought I would post it. Very simple but for us non sys-admins not easy to remember.

I put a fresh install of ubuntu on my machine and got LAMP all set up. Quick and easy guide for install can be found here. I don’t like using the /var/www/ directory for development and prefer to have all my documents in my /home directory. My /home directory lives on a seperate partition for easy OS installs and it makes it easy to backup all my data at once.

So you have LAMP all set up. When you type in http://localhost/ you get the apache message “It works!”. Now we are going to make localhost point to a directory in home, I call it webroot.

First lets make the folder. Fire up your terminal.

sudo mkdir webroot

Next I change permissions in the folder. I already have a bunch of sites so we will do it recursively.

sudo chmod 777 -R webroot

Now lets edit the “sites-enabled” in apache. Open up the “000-default” document with root permisions.

sudo gedit /etc/apache2/sites-enabled

At the top change the line that says:

NameVirtualHost *
 
	ServerAdmin webmaster@localhost
 
	DocumentRoot /var/www/

to

NameVirtualHost *
 
	ServerAdmin webmaster@localhost
 
	DocumentRoot /home/darren/webroot/

Of course you should change “darren” to your user name. Now lets restart apache.

sudo /etc/init.d/apache2 restart

Thats it if you put http://localhost/ into your browser it will point to whatever files you have in webroot (or whatever you want to call it).

Posted in ubuntu | No Comments »