2

I am trying to deploy my Laravel app in apache2 locally, however when trying to browse to http://myapp.localhost.com/ 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 80

I 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.com

Any 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
  • If needed PM me. I'll have a look to any questions you have. But your virtual host seems to be missing some options ;) – Rinzwind Jan 16 '15 at 19:09
  • sure, I'd like you to ask you soome questions – dabadaba Jan 16 '15 at 19:27
2

I am missing the

Options Indexes FollowSymLinks Includes ExecCGI

in 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?

5
  • I added Options Indexes FollowSymLinks Includes ExecCGI and Require all granted and now it works. I am trying to access my application through my mobile phone (which is in the same network), however when browsing myapp.localhost.com I am not getting the page. How can I do this? – dabadaba Jan 16 '15 at 19:15
  • I would start by checking apache log and see if your mobile reaches your site. If it does not: router. If it does it will have a error notice. – Rinzwind Jan 16 '15 at 19:30
  • I am not sure what I should be looking at in the log to see what you're saying. I can see a line in the access.log that some lines go like this 192.168.1.135 - - [16/Jan/2015:20:14:54 +0100] "GET /favicon.ico HTTP/1.1" 404 502 "-" "Mozilla/5.0 (Linux; Android 4.4.4; XT1032 Build/KXB21.14-L1.40) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.93 Mobile Safari/537.36" it says Android so it has tobe the phone – dabadaba Jan 16 '15 at 19:49
  • Yes it will be the phone. Means the problem is in the site itself probably and not in the network. – Rinzwind Jan 16 '15 at 19:59
  • how is the problem in the site? it works in my machine, why wouldn't it work in the phone? – dabadaba Jan 16 '15 at 20:09
0

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/cache

At the end restart your apache2:

sudo service apache2 restart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.