I am trying to deploy my Laravel app in apache2 locally, however when trying to browse to I am getting the following error:
Forbidden
You don't have permission to access / on this server.
Apache/2.4.7 (Ubuntu) Server at myapp.localhost.com Port 80I created myapp.conf in /etc/apache2/sites-available to set up the virtual host:
<VirtualHost *:80> ServerName myapp.localhost.com DocumentRoot "/home/user/projects/myapp/public" <Directory "/home/user/projects/myapp/public"> AllowOverride all </Directory>
</VirtualHost>And created a symlink in /etc/apache2/sites-enabled (sudo ln -s ../sites-available/myapp.conf)
Also edited the /etc/hosts file and added:
127.0.0.1 myapp.localhost.comAny clue why I am getting this error? I am also having the same problem when trying to deploy the application to heroku, which also uses apache2.
2 Answers
I am missing the
Options Indexes FollowSymLinks Includes ExecCGIin your myapp.conf. As of Apache-2.4 mod_authz_host is used and Require (example Require all granted) should be used.
By the way... this:
You don't have permission to access / on this server.
I remember from the apache as the default when using httpd.conf. Are you sure the sites-*/* are being used?
In your VirtualHost write the DocumentRoot to point to your Laravel Application in your home directories. In addition you must add the Directory shown below, with your own path.
<Directory /home/john/Laravel_Projects/links/public/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all Require all granted
</Directory>The second step, you must go to your Laravel Project and run the following command.
sudo chmod -R 777 storage bootstrap/cacheAt the end restart your apache2:
sudo service apache2 restart