Skip to content

Apache’s Directives

May 7, 2012

I wanted to change the directory where my website tree begins from, i.e. /usr/local/apache2/htdocs/index.html (this is the same website that I used to acknowledge that the Apache webserve is working correctly). In past verions of Apache webserver the normal tree directory would have been in the directory  /var/www/index.html

I did a bit more research into how to go abouts doing this by looking into Apache’s httpd website. I found out that to change where my websites hireachy begins I will need to change a “directive” called “DocumentRoot” to the directory that I would want my website’s hireachly to begin at. So basically to conifgure certain aspects of Apache’s webserver I need to change the value of a option called a “directive”.

Here is how I changed my websites hierachy from /usr/local/apache2/htdocs to /var/www : –

I found the “directive” that I needed to change by looking at the following URL: –

I then went to the configuration file of  Apache (httpd.conf) and amended the value so that it now points to /var/www: –

prompt> cd /usr/local/apache2/conf/

prompt> vi httpd.conf

amended the httpd.conf so that it now read: –

DocumentRoot “/var/www”
<Directory “/var/www”>

I created the directory as it was not present and then put a index.html file in it: –

prompt> sudo mkdir /var/www/

prompt> cd /var/www/

prompt> cat > index.html # Hit return, this will now let you enter data that will populate the index.html file that you have just created, make sure to type/copy the below line starting from <html> into your terminal

<html><body><h1>This website’s hireachy is now from /var/www !</h1></body></html>

# once done press Control D on your keyboard

It looks like you need to restart the Apache webserver for the changes to take place: –

prompt> service httpd restart

As always make sure to test to make sure the changes have been made. In this instance I included text in the html file above to say that it is from the /var/www directory. So once I went into an internet browser and type local host or it showed me the changes I made were successfull


From → Linux

  1. Very nice blog, thanks for share this article with us

  2. This website has some very useful info on it! Cheers for helping me.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: