Make backup copy of Apache default file with below command
#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.conf.bak
Edit 000-default.conf file to give DocumentRoot path
#sudo nano /etc/apache2/sites-available/000-default.conf
and change the following line with you new path:
DocumentRoot /var/www/html (Default Line)
To
DocumentRoot /mywebsite (Your website path)
after make changes in this file. Save and Close 000-default.conf file.
Now, Open apache.conf file and change the DocumentRoot path here as well.
#sudo nano /etc/apache2/apache2.conf
and find this
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and change /var/www/html to your preferred directory and save it.
After made changes in both files, just restart the apache2 webserver.
Use below command to restart apache server.
#sudo service apache2 restart
OR
#sudo /etc/init.d/apache2 restart
If you will receive permission error check the user of apache and give the permission.
To check user of apache run below command.
#ps aux | grep apache
Above command will show like this.
Then run below command to give permission.
#sudo chown -R $USER:$USER /mywebsite
The $USER variable will take the value of the user you are currently logged in
Give permission to folder with below command
#sudo chmod -R 755 /mywebsite
Now restart the webserver.
#sudo service apache2 restart
OR
#sudo /etc/init.d/apache2 restart
Check Now !!
#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.conf.bak
Edit 000-default.conf file to give DocumentRoot path
#sudo nano /etc/apache2/sites-available/000-default.conf
and change the following line with you new path:
DocumentRoot /var/www/html (Default Line)
To
DocumentRoot /mywebsite (Your website path)
after make changes in this file. Save and Close 000-default.conf file.
Now, Open apache.conf file and change the DocumentRoot path here as well.
#sudo nano /etc/apache2/apache2.conf
and find this
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and change /var/www/html to your preferred directory and save it.
After made changes in both files, just restart the apache2 webserver.
Use below command to restart apache server.
#sudo service apache2 restart
OR
#sudo /etc/init.d/apache2 restart
If you will receive permission error check the user of apache and give the permission.
To check user of apache run below command.
#ps aux | grep apache
Above command will show like this.
Then run below command to give permission.
#sudo chown -R $USER:$USER /mywebsite
The $USER variable will take the value of the user you are currently logged in
Give permission to folder with below command
#sudo chmod -R 755 /mywebsite
Now restart the webserver.
#sudo service apache2 restart
OR
#sudo /etc/init.d/apache2 restart
Check Now !!