Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Gil401's avatar

Deploying Laravel to EC2

Hi Guys,

I have my laravel project all working on my localhost. I deployed it to EC2, and nothing comes up. All I see in the dev console is internal error (500).

What am I missing? What do I need to change before deploying to AWS? Here is the URL: ec2-52-88-99-75.us-west-2.compute.amazonaws.com

0 likes
9 replies
ejdelmonico's avatar

I've never deployed to EC instance but did you verify that there is a .ENV and make any necessary corrections to .htacess files? Just a thought.

jjosephs's avatar

I just deploy mine through aws elastic beanstalk. Costs just about the same as running an EC2 instance with no level server configuration to worry about.

With Laravel 5.1 I just zip the entire folder and upload it through the beanstalk web interface.

rajiv's avatar

Assuming that you have installed apache, mysql, openhttp,mcrypt and that you are trying to make things work on Ubuntu

  1. Check if mod rewrite is enabled - sudo a2enmod rewrite
  2. Give permissions to your storage and vendor folders - chmod 755 -R laravel and then chmod -R o+w storage 
  3. Check if you app.config has the environment variables set correctly including the 'url' . Set it to point to the right URL.
  4. If you are using database ensure that you have your database.config set to the correct database for e.g. mysql. Set the database, user id and password
  5. Go to /etc/apache2/sites-available/ and change your Document root to point to your Laravel public folder. (the one where you have your project installed)
  6. Go to /etc/apache2 and use either of mcedit/vi/nano apache.conf and make the following modifications to /var/www/, you may also want to add this as an additional entry Assuming this is your DocumentRoot "/var/www/html/laravel/public/" <Directory "/var/www/html/laravel/public"> Allowoverride All Require all granted
  7. Restart your apache-> apachectl restart or use a command that you find to handy.

Test your pages -- oops problem? Are you getting a file not found issue. Try the following. Check your .htaccess for correctness.

Sometimes you may come across crytp issues this is caused due issues with your key. Try the following..

In your console write: "php artisan key:generate". Secondly, get the 32 characters to config/app.php like 'key' => env('APP_KEY', 'insert get 32 char key')

restart Apache again.

you may also want to clear the route cache by typing in the following

-> php artisan route:clear

Other issues that you would encounter is table not found. If you were developing on windows environment and have deployed the code to aws chances are that these are caused due to case sensitivity of linux environment.

5 likes
christopher's avatar

@mayank_8jun did you set up your security group? e.g open port 80 for http requests? Since you IP is not reachable

1 like
christopher's avatar

What is with the outbound traffic? Did you allow all traffic?

Because the site isnt reachable so it could be that all outbound traffic is blocked.

rajiv's avatar

@mayank_8jun did you terminate your aws infrastructure and create a new one. Check your ip.

When i tried, the error states that the site cannot be reached!

Did you try deploying a simple html page and try reaching it?

Please or to participate in this conversation.