Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 12: Technology Stacks — LAMP, LEMP, MEAN, MERN

Hello friends! Words like LAMP and MERN always appear in job postings. In this chapter we will build four complete stacks on EC2 – LAMP, LEMP, MEAN and MERN. Example: a small notes app for a dairy brand like Amul (sample data, for practice). First draw each stack's request flow on paper, then type the commands with me.

What you will learn in this chapter

  • What a stack is
  • LAMP and LEMP install
  • MEAN and MERN architecture
  • MongoDB from the official repo
  • Express + MongoDB API
  • React and Angular builds
  • Serving SPAs with Nginx
  • Comparing the four stacks

Concepts in this chapter

  1. 12.1What is a "stack" and why does it matter?
  2. 12.2LAMP stack
  3. 12.3LEMP stack
  4. 12.4MEAN and MERN architecture
  5. 12.5Installing MongoDB from the official repository
  6. 12.6Common backend API for MEAN and MERN (Node + Express + MongoDB)
  7. 12.7MERN: React frontend served by Nginx
  8. 12.8MEAN: Angular frontend served by Nginx
  9. 12.9Stack comparison summary

Review and practice

  1. ★Common Mistakes I See Students Make
  2. ★Interview Questions
  3. ★Practice Questions and Lab Exercises

Stacks in the real world

A "stack" is a set of technologies that work together to run an app. LAMP (Linux, Apache, MySQL, PHP) powers a large share of the web, including most WordPress sites. LEMP swaps Apache for nginx. MEAN and MERN use JavaScript end to end: MongoDB, Express, Angular or React, and Node.js. Job posts in India often mention these names, and you will meet them in companies of every size.

Other popular stacks follow the same pattern: Spring Boot + React + PostgreSQL (common in banks and large IT services companies), ASP.NET Core + Angular + SQL Server (common in enterprises using Microsoft tools), Django + PostgreSQL and Rails + PostgreSQL (common at startups), and Go + PostgreSQL + Redis for high-performance APIs. In every one, the web server is in front, the app runs privately and the database is never public. This chapter builds four stacks so that this pattern becomes second nature.

Every stacknginx / ApacheApp(PHP, Node, Java,.NET, Python, Go)Database(MySQL, PostgreSQL,MongoDB)
All stacks share one shape. Only the tools inside the boxes change.

After this part you will be able to

  1. Explain LAMP, LEMP, MEAN and MERN with a diagram.
  2. Install MongoDB from the official repository.
  3. Build and serve React and Angular apps with nginx.
  4. Choose a stack based on the team and the data.

Everyday analogy: different cuisines, same kitchen rules. Whatever you cook, the gas, the fridge and the cleaning rules stay the same.

Key terms

  • Stack: A set of technologies used together.
  • SPA: Single-page app (React, Angular), built to static files.
  • REST API: An HTTP interface returning JSON.
  • try_files: The nginx rule that lets SPA routes work on refresh.
  • bindIp: The MongoDB setting for which addresses it listens on.
  • ODM / ORM: Libraries that map objects to documents or tables, such as Mongoose, Hibernate, EF Core and Django ORM.

Mini case study

Suppose we are a junior cloud engineer at a Bengaluru e-commerce startup (sample data). The team runs a PHP admin, a Node.js storefront API and a Python report job on two EC2 instances. Using this chapter, you write a one-page runbook: which service listens where, how to test and reload each one, which logs to read, and which ports are public (only 80 and 443, plus 22 from the office IP). New team members can then fix most problems on their own.

Practice Tasks

About this scenario

Kolhapuri Chappal Co is a footwear business in Kolhapur. Sachin Mane looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 12

Easy Install a package on Ubuntu

Why: Ubuntu uses apt. Package names differ: on Ubuntu Apache is apache2.

What to do: Install the apache2 package on Ubuntu without being asked to confirm.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Install a package on Amazon Linux

Why: dnf is the package manager on Amazon Linux 2023. -y answers yes for you.

What to do: Install the httpd package on Amazon Linux 2023 without being asked to confirm.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Restart a service after a change

Why: Config changes only apply after the service restarts or reloads.

What to do: Restart the nginx service.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Check if a service is running

Why: When a site is down, first check whether the web server process is running.

What to do: Show the status of the httpd service.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Log in to MariaDB

Why: The mysql client lets you run SQL on the database server.

What to do: Open the MariaDB client as user root and ask for the password.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Biggest orders first

Why: Querying the database is daily work after you set up RDS.

What to do: Show order id and amount, biggest amount first.

Tables: customers(id, name, city) and orders(id, customer_id, amount, odate).

How:
  1. Find the table the task is about (see the table list above the box).
  2. Write the SQL statement step by step: what, from where, which rows.
  3. End the statement with ;
  4. Click Check answer. Your query runs on a practice copy of the table.

Easy Filter customers by city

Why: Querying the database is daily work after you set up RDS.

What to do: List the names of customers in Pune.

Tables: customers(id, name, city) and orders(id, customer_id, amount, odate).

How:
  1. Find the table the task is about (see the table list above the box).
  2. Write the SQL statement step by step: what, from where, which rows.
  3. End the statement with ;
  4. Click Check answer. Your query runs on a practice copy of the table.

Medium Start a service now and at boot

Why: enable makes it start after reboot; --now also starts it right away.

What to do: Enable the nginx service and start it immediately, in one command.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Remove small orders

Why: Querying the database is daily work after you set up RDS.

What to do: Delete orders with amount below 200.

Tables: customers(id, name, city) and orders(id, customer_id, amount, odate).

How:
  1. Find the table the task is about (see the table list above the box).
  2. Write the SQL statement step by step: what, from where, which rows.
  3. End the statement with ;
  4. Click Check answer. Your query runs on a practice copy of the table.

Medium Orders with customer names

Why: Querying the database is daily work after you set up RDS.

What to do: Show each customer name with each order amount.

Tables: customers(id, name, city) and orders(id, customer_id, amount, odate).

How:
  1. Find the table the task is about (see the table list above the box).
  2. Write the SQL statement step by step: what, from where, which rows.
  3. End the statement with ;
  4. Click Check answer. Your query runs on a practice copy of the table.

Hard Sales per customer

Why: Querying the database is daily work after you set up RDS.

What to do: Show customer_id and total amount per customer, only where total is above 1000.

Tables: customers(id, name, city) and orders(id, customer_id, amount, odate).

How:
  1. Find the table the task is about (see the table list above the box).
  2. Write the SQL statement step by step: what, from where, which rows.
  3. End the statement with ;
  4. Click Check answer. Your query runs on a practice copy of the table.

Hard Customers with no orders

Why: Querying the database is daily work after you set up RDS.

What to do: List names of customers who have never ordered.

Tables: customers(id, name, city) and orders(id, customer_id, amount, odate).

How:
  1. Find the table the task is about (see the table list above the box).
  2. Write the SQL statement step by step: what, from where, which rows.
  3. End the statement with ;
  4. Click Check answer. Your query runs on a practice copy of the table.