How to change the DocumentRoot of apache2 in Ubuntu

mantle power How to change the DocumentRoot of apache2 in UbuntuThe new apache2 came with a lot of changes. Almost every thing was changed from the location of the files to their names too. So if you go looking for the previous config files you won’t find them.

So if you want to change the DocumentRoot in apache2 you will not find the setting under httpd.conf. To chance the DocumentRoot of the apache2 server follow the steps:

STEP1: First you need to make the directory to which you want to change the DocumentRoot to. Preferably make this directory in your home folder so that you have all the permissions to edit the files that are kept in the folder. So issue the command

mkdir ~/name_of_your_folder

STEP2: To change the DocumentRoot you would need to edit the file default file placed in /etc/apache2/sites-available . So issue the command

sudo gedit /etc/apache2/sites-available/default

In this file you would see something like

DocumentRoot /var/www/

Change it to

DocumentRoot /home/username/name_of_your_directory/

On line 9 you would see something like this

<Directory /var/www/>

Change it to

 

<Directory /home/username/name_of_your_directory/>

STEP3: Save the file.  Go to the terminal and issue the command

sudo /etc/init.d/apache2 restart

And its done. Now place any of your file in the folder you made and you would be able to see the file by going to http://localhost/

IF you have any queries regarding the process feel free to leave a comment.

Share With Friends

Ashmeet Singh

I have just passed class 12 and am looking forward to making it into a good college. I have also been the writer of many blogs such as TechnoDesi,NewtrojansBlog,GammersLane etc. and this blog is my new endeavour in the field of technology.

You may also like...

3 Responses

  1. Lemay says:

    i changed all that you explain, but I get a forbidden error…
    my doc root is a folder i a partition ntfs

    thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>