Change Root Directory on LAMP Server

LAMP is an archetypal model of web service solution stacks, named as an acronym of the names of its original four open-source components: the Linux operating system, the Apache HTTP Server, the MySQL relational database management system (RDBMS), and the PHP programming language.

Installing lamp server will create a root directory of an Apache server on /var/www/html. I like to change the root directory because of some permission problem on  /var/www/html and also to make easy of managing my projects on my custom directory. Here are the steps to changed root directory on LAMP server.

  • We need to change the path on the file /etc/apache2/sites-available/000-default.conf, Use the following command to edit the file.
    sudo nano /etc/apache2/sites-available/000-default.conf

    And then change the path on the following line to whatever we want
    DocumentRoot /var/www/html

  • Also, We need to change on other files /etc/apache2/apache2.conf, By Using the following command.
    sudo nano /etc/apache2/apache2.conf

    Here, We need to change /var/www/html to your preferred directory from the following and then save it.
    <Directory /var/www/html/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted

  • After we changed the path on two files we need to restart the Apache server using the following command
    sudo service apache2 restart


SIVA SANKAR, Working as a Software Engineer, Blogging is my hobby. I completed my Bachelors of Engineering (Computer Science Engineering) in Chennai, India. and my Master of Engineering (Embedded System Technologies) in Tamilnadu, India.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.