Voiced by Amazon Polly |
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
Customized Cloud Solutions to Drive your Business Success
- Cloud Migration
- Devops
- AIML & IoT
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
Setting Up and Accessing EC2 Instance
- 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
1 2 3 4 5 |
sudo apt update -y sudo add-apt-repository ppa:ondrej/php sudo apt update -y sudo apt install php php --version |
Step 2 – Next, let’s install composer
1 2 3 4 5 6 |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');" sudo mv composer.phar /usr/local/bin/composer composer --version |
Step 3 – Install npm & nodeJS
1 |
sudo apt install nodejs npm -y |
Step 4 – Install php module for mysql. Install php-curl & php-xml extensions
1 2 3 |
sudo apt install php-mysql -y sudo apt-get install php-curl -y sudo apt install php-xml -y |
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
1 2 3 4 5 6 7 8 |
$ sudo apt install mysql-server -y $ sudo mysql -u root mysql > CREATE DATABASE lms; CREATE USER 'lmsuser'@'%' IDENTIFIED BY 'lmspassword'; GRANT ALL ON lms.* TO 'lmsuser'@'%'; exit $ mysql -u lmsuser -p mysql> exit |
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
1 2 3 4 |
git clone https://github.com/aneez004/LMS-Laravel.git cd LMS-Laravel cp .env.example .env vim .env ### Add db details, save and exit |
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
1 2 3 4 5 6 |
composer update php artisan key:generate php artisan migrate npm install php artisan db:seed php artisan serve --host=0.0.0.0 --port=8000 |
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.
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.)
1 2 |
zip ../laravel-lms.zip -r * .[^.]* -x "vendor/*" -x "node_modules/*" ls ../ |
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
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 850k+ professionals in 600+ cloud certifications and completed 500+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, AWS GenAI Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, Amazon ECS Service Delivery Partner, AWS Glue Service Delivery Partner, Amazon Redshift Service Delivery Partner, AWS Control Tower Service Delivery Partner, AWS WAF Service Delivery Partner, Amazon CloudFront Service Delivery Partner, Amazon OpenSearch Service Delivery Partner, AWS DMS Service Delivery Partner, AWS Systems Manager Service Delivery Partner, Amazon RDS Service Delivery Partner, AWS CloudFormation Service Delivery Partner, AWS Config, Amazon EMR and many more.
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
Comments