8

I am trying to set up my laravel project on my EC2 Instance for AWS. I have successfully uploaded the files to the server using SFTP, and I rewrote the 000-default.conf file to point to the public folder of the project.

The home route is loading fine, but none of the other routes are working? Any idea what is going on here? They all work fine on local host (MAMP) and on other servers.

All of the other routes show a NOT FOUND page (The requested URL /fans was not found on this server (for instance) )

6
  • Does index.php/fans work? Commented Mar 19, 2014 at 0:08
  • it does, but then none of the image paths work because I have it using pretty urls (so index.php doesn't show up). So ec2-etc..etc../fans doesn't work, but ec2-etc..etc../index.php/fans does. Commented Mar 19, 2014 at 0:30
  • Sounds like a mod_rewrite isn't enabled then. Not sure how EC2 instances work, but if you can SSH in an it's Apache then just enable it with a2enmod rewrite then restart Apache. Commented Mar 19, 2014 at 0:35
  • which apache file do I put this in? Commented Mar 19, 2014 at 0:49
  • It's a command, so simply run a2enmod rewrite, you may need to elevate yourself with sudo, not sure how it works on Amazon. Commented Mar 19, 2014 at 0:54

3 Answers 3

21

This worked for me:

First in 000-default.conf

Make Document Root point to your public folder:

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html/your/laravel-project-folder/public/

Then add this to end of the 000-default.conf:

<Directory "/var/www/html/your/laravel-project-folder/">
    AllowOverride All
</Directory>

Last two steps:

run this as root user:

1. sudo a2enmod rewrite
2. service apache2 restart

Now everything was working fine for me.

Hope this helps :)

2
  • 1
    Worked like a charm
    – coder29
    Commented Jan 22, 2017 at 5:07
  • AllowOverride All It's just allow to your web files acceess from your server. Normally its does not able to access the file that's why we set AllowOverride All. There is no risk for your web to miscellaneous access. It's say allow access for .htaccess file from apache2 server. Here is the link for more details about AllowOverride All. httpd.apache.org/docs/2.4/mod/core.html#allowoverride Commented Mar 12, 2020 at 4:42
8

For people who have this issue in the future:

All I had to do was add:

<Directory /var/www>
AllowOverride All
</Directory>

to my 000-default.conf file in /etc/apache2/sites-available directory.

Place it right under the DocumentRoot line.

Cheers.

0
0

I met the same problem when I use Laravel5.2 on AWS. Can you see the welcome page after you deploy laravel on AWS? You can use the following to access the welcome page. /public/index.php

If you can do above, then you modify your route.php in the app/Http/ folder, like this:

Route::get('/convert/{name}', function ($name) {
     return str_plural($name);
});

After that you can try "/public/index.php/convert/123". Then you will see "123s" on the screen.

It is really tricky to visit your route with /public/index.php/, it waste long time for me to fix this problem.

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