AJ Seraspi
AJ Seraspi

Reputation: 113

Laravel returns 500 internal server and 404 on routes after deploying to Amazon EC2

I like to ask help on how to fix the 500 internal server and 404 when using laravel routes after deploying it to Amazon AWS.

enter image description here

I tried to clear the cache and restarting the apache2 but no luck.

Also I do change the permissions of the folders enter image description here

I also change the 000-default.conf file enter image description here

Until now, no luck on my side. Did I miss something or do I need change some configurations? Please let me know and Thanks in Advance!

Upvotes: 2

Views: 1069

Answers (2)

sudip-modi
sudip-modi

Reputation: 96

In my case it was a problem with the php version. My project was using 7.4 but the ec2 ubuntu machine i was using was version 22 which was installing php 8.1. I created a new ec2 machine of version 20.04 ubuntu os. And installed php7.4 and all other php dependencies at 7.4 version. One more problem that i was facing related to this was the write access permission to the app/storage/logs folder. I resolved this using the "chmod -R 777 /var/www/myprojectname/app/storage" command. Hope this is helpful

Upvotes: 1

Hassaan Ali
Hassaan Ali

Reputation: 1061

The main reason is that composer is using your localhost configuration you've to reconfigure your laravelapp on your ec2 instance. Try these commands in order:

1. composer dump-autoload

2. PHP artisan config:cache

3. PHP artisan optimize

and then check your laravel application for your ec2 instance.

Upvotes: 2

Related Questions