AWS, Cloud Computing

6 Mins Read

A Guide to Deploy LMS on EC2 Using Laravel Framework

Overview

This is the first part of the three-part blog series where we will be deploying a Learning Management System (LMS) using PHP Laravel on the following AWS services:

  • AWS EC2
  • AWS Elastic BeanStalk
  • ECS

Introduction

PHP Laravel is one of the most popular web application frameworks in the world. It is a simple and elegant framework that can be used to build complex applications, like e-commerce solutions, content management systems (CMS), and more.

A learning management system (LMS) is a piece of software used for managing, documenting, tracking, reporting, automating, and delivering educational programs, training materials, and courses. The idea of a learning management system was born out of e-Learning.

In this tutorial, we’ll go through the step-by-step process of installing LMS using PHP Laravel on AWS EC2 instances with the Ubuntu 20.04 LTS operating system. It can be tested and tried out easily by anyone even without any prior experience.

Prerequisites:

  • An AWS Account
  • IAM user with permission to create the required resources

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Setting Up and Accessing EC2 Instance

  1. Spin up an AWS EC2 instance with the following specifications:
  • Suitable name (eg: php-laravel-lms)
  • Ubuntu 20.04 LTS
  • medium instance type
  • A key pair to which you have access (Or create a new keypair and save the same)
  • A security group that provides access to ports 8000 and 22 from our public IP
  • Public subnet (or use a loadbalancer and forward traffic to the instance in the private subnet.)
  • 30 GB of storage (gp3)

2. Connect to the EC2 instance using SSH utilizing the keypair.

Follow this AWS documentation in case of questions:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-instance-wizard.html

Step to Deploy PHP Laravel LMS on AWS EC2

Before you can deploy your PHP Laravel LMS on AWS EC2, you will need to install some tools.

Step 1 – Install PHP

Add repository and install PHP 8.1

Step1

Step1b

Step1c

Step1d

Step 2 – Next, let’s install composer

Step2

Step 3 – Install npm & nodeJS

Step3

Step 4 – Install php module for mysql. Install php-curl & php-xml extensions

Step4

Step4b

Step4c

Step 5 – Install and configure mysql-server

  • Create a database ‘lms’
  • Create a database user lms_user with password lms_password
  • Grant all privileges on the lms database for the user lms_user
  • Verify access to the mysql server using lms_user and lms_password

Step5

Step5b

Step5c

Step5d

Step5e

Step 6 – Clone the GitHub repository holding the application. Navigate the application directory.

  • Make a copy of the .env.example file with the name .env
  • Add the database details to the file.
  • Install the dependencies using the composer

Step6

Step6b

Step6c

Step 7 – Execute the following commands which will

  • Compose update will install/update all the PHP dependencies
  • Generate an application key and add it to the .env file
  • php artisan migrate – publishes all our schema to the database. This command also creates the table in the database.
  • npm install to manage dependencies.
  • The db:seed command is used to add records to a database automatically using a Seeder class to generate or provide the records.
  • PHP artisan serve command helps run applications on the PHP development server

Step7

Step7b

Step7c

Step7d

Step7e

Step7f

Step7g

Step7h

Step 8 – Save the login credentials for the Admin, User, and Teacher roles.

Step 9 – Access the site using the public IP of the instance and port 8000. Enter the credentials for the ‘Admin’ user.

Step9

Step9b

Step 10 – Navigate to the application directory.

  • Create a zip out of the same. Download the zip file to the local machine or upload it to an s3 bucket. This can be used to deploy the same LMS on ElasticBeanStalk, which will be explained in the upcoming blog post. (Use ‘aws configure’ and provide access and secret key. Or add IAM role and policy relevant to push files to AWS S3.)

Step10

Step10b

Step10c

Conclusion

In this tutorial, we learned to spin up an EC2 instance and deploy all the dependencies that are required to set up and access a Learning Management System (LMS) using the PHP Laravel framework. MySQL server was used as the database. Laravel’s robust queue system can process jobs using Redis, Amazon SQS, or even MySQL and Postgres which we can explore in a future blog session.

I hope this helped you configure your own LMS using Laravel on AWS EC2. If you have any questions, feel free to leave them in the comments section below

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding Laravel framework and I will get back to you quickly.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.

FAQs

1. Why is Laravel better than other frameworks?

ANS: – The first advantage that justifies the much higher popularity of Laravel compared to other PHP frameworks is that it follows a Model-View-Controller-based software design pattern. It ensures clarity between logic (Model) and presentation (View) through the lens of the Controller, which results in overall performance improvement, and better documentation readability. Laravel’s Blade templating engine is another advantage. It allows using inbuilt lightweight templates to create class-based components that can be reused anywhere in your PHP application. The primary aim in doing so is to create amazing layouts as a result of taking advantage of dynamic content seeding.

2. What is the client base of LMS?

ANS: – LMS platforms can be used by clients who want to implement online training sessions. This will facilitate on-demand training; thus, making the e-learning process low-cost and efficient. The clients can design courses suited to online learning sessions for situations like employee inductions and internal refresher training.

3. What is AWS EC2?

ANS: – AWS Elastic Compute Cloud (EC2) provides resizable compute capacity in the cloud, which is designed to make web-scale computing easier and more cost-effective than traditional on-premises servers. The most popular use of EC2 is hosting websites and other applications that have high traffic or require high performance. However, you can also use it for other purposes such as running bots, testing your application, and developing prototypes.

WRITTEN BY Anees A

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!