Apache can't access folders in my home directory
Solution 1:
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
Solution 2:
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 tohttp://localhost/~yourname
from your web browser.