Complete Guide
Deploy any Laravel App in AWS (Amazon Web Services)
Using AWS EC2 + RDS (Ubuntu, MySQL RDS)
Monday, April 19, 2021 (MDT)
Author: Emad ZaamoutCheck if your website is working
Table of Contents
Deploying Laravel applications the correct way in 10 Steps using AWS.
In this tutorial we will cover
-
Domain Registration
-
Elastic IP Address
-
Security Groups
-
Launching RDS instance (For MySQL DB)
-
Launching EC2 Linux Ubuntu Instance
-
Requirements Gathering & Preparations
-
Importing Laravel Project & Setting up folder permissions
-
Installing & configuring Apache2, Installing Composer & Dependencies
-
SSL Certification using Certbot
-
[Optional] CloudWatch & Automated Notifications
Commands
Connect to EC2 Instance using SSH & PEM file.
ssh -i {pem file} {user}@{ip address}
Connect to your RDS MySQL Server.
mysql -h {rds_endpoint} -P 3306 -u admin -p
MySQL - Show Database
SHOW Databas;
MySQL - Create Database
CREATE DATABASE {db-name};
Git initialize local repository and configure user name and email
git init
git config --global user.email "support@ahtcloud.com"
git config --global user.name "Emad Zaamout"
Git configure remote origin
git remote add origin {bitbucket-repositry-url}
Git force push local changes and track remote origin master branch
git push -u -f origin master
Git Pull your project
git pull {bitbucket repository}
Laravel Ubuntu Linux Server Setup
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install apache2
sudo apt-get install software-properties-commo
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt-get install php7.4
sudo apt install php-curl php-cli php-mbstring git unzip php7.4-mysql php7.4-dom php7.4-xml php7.4-xmlwriter phpunit php-mbstring php-xml
sudo apt install python3-certbot-apache
Install Composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'c31c1e292ad7be5f49291169c0ac8f683499edddcfd4e42232982d0fd193004208a58ff6f353fde0012d35fdd72bc394') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Move composer.phar to bin/composer to make composer command executable
sudo mv composer.phar /usr/local/bin/
Laravel Setup on Production Server
php artisan migrate
php artisan key:generate
Correct Laravel Folder Permissions
sudo chown -R www-data storage
sudo chown -R www-data storage/framework
sudo chmod g+w -R storage
sudo chmod g+w -R storage/framework
sudo chmod g+w -R storage/framework/sessions/
sudo chmod g+w -R storage/logs/
Create Apache2 Virtual Host configuration file for your project.
<VirtualHost *:80>
ServerAdmin support@ahtcloud.com
ServerName greencleaningservices.ca
ServerAlias www.greencleaningservices.ca
DocumentRoot /var/www/greencleaningservices/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/greencleaningservices>
Require all granted
AllowOverride All
Options Indexes Multiviews FollowSymLinks
</Directory>
</VirtualHost>
Check if your website is correctly configured by using our free tool.
Check if your website is workingOther Posts
GET YOUR FREE ESTIMATE
CONTACT US TODAY FOR YOUR FREE CONSULTATION!
Contact us today to discuss your goals and we will create a simple roadmap to get you there. We look forward to speaking with you!
Main Office
Phone: 1 587-834-6567
Email: support@ahtcloud.com
32 Westwinds Crescent NE #130
Calgary, AB T3J 5L3, CA
Products
TMS
Cloud Based Transportation Management System
Hours Of Operation
Monday | 8:00 am - 5:00 pm |
---|---|
Tuesday | 8:00 am - 5:00 pm |
Wednesday | 8:00 am - 5:00 pm |
Thursday | 8:00 am - 5:00 pm |
Friday | 8:00 am - 5:00 pm |
Saturday | Closed |
Sunday | Closed |