403 Forbidden after changing DocumentRoot directory Apache 2.4.6 [duplicate]
I had the exact same problem and I solved it like this:
First; I followed the steps as explained on the Ubuntu Server Guide Pages
- Go to terminal and copy the default virtual host configuration to a new one
(
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mynewsite.conf
) - Edit this new file (
sudo gedit /etc/apache2/sites-available/mynewsite.conf
) and change the DocumentRoot to your own (save and close..) -
Enable this new configuration file (
sudo a2ensite mynewsite.conf
) and dissable the default one (sudo a2dissite 000-default.conf
) - Edit the apache2.conf (
sudo gedit /etc/apache2/apache2.conf
) and change the default -section into this:<Directory [write_your_dir_here]> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
(save and close..) - Restart Apache2 (
sudo service apache2 restart
)
If it already works: great!
If not then you should check if every named based <VirtualHost *:80>
requires a distinct ServerName
set, including 000-default.conf
if it exists. You can run apachectl -S
in the terminal to see a quick list of everything.
If it still does not work then you should check if your directory (and the full path leading up to it!) has the right read and execute-permissions (r-x).
- Go to your root (
cd /
) and dols -l
where you can see something likedrwxr-xr-x 14 root root 4096 mei 1 01:24 [your_directory]
. - All your directories leading up to the www-folder should have the "drwxr-xr-x"-permissions, if not you can change it using
sudo chmod -R a+rx [your_directory]
If you still can't get it to work, you should check the apache error-log (sudo gedit /var/log/apache2/error.log
) and dig further...
Good luck!
Dear I wanted to inform you that you are changing your default apache configuration.
Remove these line from your 000-default.conf file.
<Directory /home/everett/webroot>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Require all granted
</Directory>
Open your your apache.conf file (/etc/apache2/apache.conf) and find out Directory or go to line no. 172. where you find out "directory /var/www/" Define your Directory "/home/everett/webroot" here save and restart your apache and refresh your web page.