Apache can't access folders in my home directory
This worked for me
<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
The important bit was to change
Order allow, deny
to
Require all granted
Enable userdir
module:
sudo a2enmod userdir
Enable PHP execution in user directory:
sudo nano /etc/apache2/mods-available/php5.conf
(Or if using php7.0, for example)
sudo nano /etc/apache2/mods-available/php7.0.conf
Comment this part (put #
at the start of each line):
#<IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_flag engine Off
# </Directory>
#</IfModule>
Press Ctrl+X to save
Enable directory listing:
sudo nano /etc/apache2/apache2.conf
Add this:
<Directory /home/*/public_html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Press Ctrl+X to save
Restart apache (sudo
required here also):
sudo service apache2 restart
Now put your php files in /home/yourname/public_html
directory and go to
http://localhost/~yourname
from your web browser.
Apache runs as user www-data
. If it doesn't have execution permission on your home, apache will not be able to read any file.
Change you home's group to www-data
:
chgrp www-data /home/dbugger
And give it permission only to traverse your home directory:
chmod g+x /home/dbugger
You can also restrict permisions of /home/dbugger/html
:
chgrp www-data /home/dbugger/html
chmod 750 /home/dbugger/html