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

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

Practice Questions and Lab Exercises

Come on, now practice! Deploy at least one PHP stack and one JavaScript stack yourself, and check whether everything comes back after a reboot.

  1. Expand LAMP, LEMP, MEAN and MERN. Draw the architecture diagram of any two.
  2. Differentiate LAMP and LEMP. Why is PHP-FPM needed in LEMP?
  3. Why do we build React/Angular apps before deployment instead of running npm start?
  4. Explain try_files $uri $uri/ /index.html; in a single-page app.
  5. Write the steps to install MongoDB from the official repository on Ubuntu 24.04.
  6. Which ports must be open in the security group for a MERN app? Which must never be open?
  7. Lab: Build a LAMP server on Amazon Linux 2023 and run dbtest.php.
  8. Lab: Build a LEMP server on Ubuntu and show phpinfo().
  9. Lab: Deploy the MERN notes app on Ubuntu 24.04. Reboot and verify that MongoDB, the API (pm2) and Nginx all come back.
  10. Lab: Deploy the MEAN notes app on Amazon Linux 2023.

Got it? LAMP, LEMP, MEAN, MERN – four names, but one pattern: web server in front, app in the middle, database behind. Now let's move on to storage – Amazon EBS.

Quick Revision

  • LAMP = Linux+Apache+MySQL+PHP; LEMP = Nginx+PHP-FPM instead of Apache.
  • MEAN/MERN = MongoDB + Express + Angular/React + Node.js — JavaScript everywhere.
  • MongoDB: official repo (mongodb-org), service mongod, port 27017, keep bindIp 127.0.0.1.
  • SPA deploy: npm run build / ng build → copy dist/ to /var/www/... → Nginx try_files ... /index.html + location /api/ { proxy_pass http://127.0.0.1:5000; }.
  • API runs with pm2 (start, save, startup).

Extra labs

  1. Lab: Spring Boot + React. Serve React dist/ with nginx and proxy /api to Spring Boot on 8080.
  2. Lab: Django + PostgreSQL. Gunicorn on 127.0.0.1:8000, nginx in front, and the security group shows only 22/80/443.
  3. Lab: port audit. Run sudo ss -tlnp on each stack. Every app or database port should show 127.0.0.1 or a private IP, never 0.0.0.0, unless a firewall restricts it.
  4. Lab: reboot test for each stack.

Expected results

CheckCommandExpected
LAMP PHP workscurl localhost/dbtest.phpConnected OK
Mongo privatess -tlnp | grep 27017127.0.0.1:27017
API upcurl localhost/api/notes[] or a JSON list
SPA routecurl -I localhost/notes/1200

Everyday analogy: after shifting house, you check each switch, tap and lock before calling it done. Do the same after every deploy.

Beginner questions I get in class

Q. How long should these labs take?
About 1–2 hours per stack the first time, and much less later.

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.