How to Change Default Apache ‘DocumentRoot’ Directory in Linux

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Marin Todorov

I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

10 Responses

  1. Tb. Progi says:

    If you install ispconfig make site server name (hosname -f) with ispconfig.

    Delete 000-default.conf

    Create symlink.

    # ln -s  /etc/apache2/sites-available/ /etc/apache2/sites-enabled/000-default.conf

    Restart apache.

    # service apache2 restart
  2. Yasser Chacon says:


    I did that and now I’m receiving Forbidden. error 403. I’m using Ubuntu 16 LTS.

  3. Saurabh Lambe says:

    Did everything as suggested. Still the html files saved in my new folder do not load in the web browser.

  4. Golden says:

    It doesn’t help i’m trying different path from DocumentRoot “/var/www/html” to /usr/share/tomcat/myApps its not worked its needs to more shape before publishing.

  5. OVVYYYXXXX says:

    Point 1 is pretty known stuff use netstat and some other commands, however it will not show all that is moved over the connection. Some things could be hidden from netstan thing…

    Point 2, and somebody bad could gain access to root sudo stuff,… I had issues with that thing, and I have tracked them to some place in africa… but after that I was not able to track them further ,…

    @ Marin Todorov I will try to use point 3 , …but chmod will not allow your file to be modified … but when moved on Windows and …then will be opened… to … well, not nice stuff….

    • Marin Todorov says:

      It sounds to me like a bad web server configuration or something like that. Try running Apache as separate user/group that way it will not be able to write outside of the given directory. While you might be familiar with some of the Apache security concepts, I would recommend you having a look at as it my contain information that can help you improve your server’s security.

  6. OVVYYYXXXX says:

    Now I would have few questions.

    1. How would I see every connection on my ps if I use netstat command?

    2. Is is possible to see the content of the root, in order to prevent some bad stuff being installed on your Linux device, as well as having chance to observe firmware into more detail.

    3. How to prevent somebody to copy some files from your pc….

    • Ravi Saive says:


      Here are the answers to your questions.

      1. Yes, you can use netstat command to list all active connections to your VPS, if you don’t know how to check, here is the advanced guide on netstat command with their practical examples

      20 netstat Command to Monitor Network Connections

      2. Unless, until someone have physical access to system, then only can someone able to install softwares…

      3. Just enable Firewall on the system and open only required ports and also if possible protect your system with grub password..

      • Marin Todorov says:

        I would like to add something to points 2 and 3.

        2 – Only users with root/sudo access can install additional packages on your system

        3 – If you want to protect files from being copied you can use chmod and chown utility so that only your user/group can access the files you want to protect

Got something to say? Join the discussion.

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.