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.

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...

5 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

  2. my blog says:

    There is small part for the concepts of ‘ventilation’, ‘blocked’
    sinuses or a easy infection in the origins of this situation.

  3. Nice weblog right here! Additionally your web site a lot up very fast!
    What host are you using? Can I am getting your affiliate hyperlink in your host?
    I wish my site loaded up as fast as yours lol

Leave a Reply to Scout Cancel 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>