Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save masudcsesust04/9e6e2b598e5eeab80dd80f2b5f54c1f1 to your computer and use it in GitHub Desktop.
Save masudcsesust04/9e6e2b598e5eeab80dd80f2b5f54c1f1 to your computer and use it in GitHub Desktop.
4 steps to change your apache default document root directory

Step - 1: Create a directory

$ mkdir /home/masud/www/

Step - 2: Open apache2 configuration file

$ sudo nano /etc/apache2/apache2.conf 
<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

Change it to

<Directory /home/masud/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
        Allow from all
</Directory>

Step - 3: Open default virtual host configuration file from path

$ sudo nano /etc/apache2/sites-available/000-default.conf 
DocumentRoot /var/www/html

Change document root to

DocumentRoot /home/masud/www/

Step - 4: Finally restart apache

$ sudo service apache2 restart
@Emile317
Copy link

This is still not working for me

chmod 755 /home/$user

change $user for your user

thanks a lot, this works

@Hi-kue
Copy link

Hi-kue commented Nov 23, 2023

This is still not working for me

chmod 755 /home/$user

change $user for your user

This works for me, thanks

@hoellthaler
Copy link

This is still not working for me

chmod 755 /home/$user

change $user for your user

Thanks to you and @masudcsesust04
It works well

@Auradomix
Copy link

This is still not working for me

chmod 755 /home/$user

change $user for your user

Worked thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment