I installed lamp stack using the bundle that came with the distro; bunsen-meta-lamp
.
After lamp installation apparmor
was installed and activated it. Root directory has been changed to /var/www/
. var/www/
and it's sub directories have %USER:$USER
read and write access (even tried 755). a2enmod
module is enabled. After every mod, Apache
service is restarted.
The result: Localhost does list the project folders. However, some projects open up in the browser; while others throw a forbidden error. The browser displays sub directories as a blank page.
Tried methods mentioned on here, here and here with no result.
Here are my 3 .conf files.
$ /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
ServerName server_domain_name_or_IP
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
$ cat /etc/apache2/apache2.conf
#ServerRoot "/etc/apache2"
#
#Mutex file:${APACHE_LOCK_DIR} default
#
DefaultRuntimeDir ${APACHE_RUN_DIR}
#
PidFile ${APACHE_PID_FILE}
#
Timeout 300
#
KeepAlive On
#
MaxKeepAliveRequests 100
#
KeepAliveTimeout 5
#
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
#
HostnameLookups Off
#
ErrorLog ${APACHE_LOG_DIR}/error.log
#
LogLevel warn
#
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
#
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
#
AccessFileName .htaccess
#
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
#
IncludeOptional conf-enabled/*.conf
#
IncludeOptional sites-enabled/*.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
cat /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
ServerName server_domain_name_or_IP
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Solved the problem with:
sudo chown -R $USER:$USER /var/www/folder-name
sudo chmod -R 755 /var/www
Grant permissions
Or try this
go to etc/apache2/apache2.conf
you will find a block with the directories and premissions the normal is:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
you can replicate this but change "/var/www/" with the new directory
then from terminal: sudo service apache2 restart