Laravel Deployment on Ec2

by John H
2 minutes

You gotta have composer installed

cd /home/ec2-user/
sudo curl -sS https://getcomposer.org/installer | php
// sudo mv composer.phar /usr/local/bin/composer

cd /var/www/html/website-directory
// make vendor folder
sudo mkdir vendor
// change permissions
sudo chmod -R 755 vendor/
// change the entire directory's group 
sudo chown -R ec2-user:apache *
sudo chmod -R ug+rwx storage bootstrap/cache
// install dependencies
composer install

Create your .env file

cp .env.example .env
php artisan key:generate

If your app requires a DB create the db (whatever steps you'd take to do that - in mysql you just create the empty db) Then run artisan migrate

php artisan migrate

This builds your db.

Your vhost should look like this - be sure it is pointed to public directory

<VirtualHost *:80>
    DocumentRoot "/var/www/html/website-directory/public"
    ServerName website.com
    <Directory "/var/www/html/website-directory/public">
    </Directory>
</VirtualHost>

If the site won't work and you are getting a server 500 error but can't seem to find out why, turn on Debugging in the .env file

APP_DEBUG=true

This can help point you in the right direction for locating the issue

Related Articles

Laravel Save Form Post

php artisan make:migration tasks in database / migrations / create tasks table - paste in up() ...

John H John H
~1 minute

Laravel Ajax Button

in blade Has Access $('.grant_access').click(function(){ var options = $(this).data(...

John H John H
2 minutes

Elastic Beanstalk Deploying an Artifact

Deploying an artifact gotto directory and eb init and select all of the configs region...

John H John H
4 minutes