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.
चला, आता प्रॅक्टिस! कमीत कमी एक PHP स्टॅक आणि एक JavaScript स्टॅक स्वतः डिप्लॉय करा, आणि रीबूटनंतर सगळं परत येतं का ते बघा.
चलो, अब प्रैक्टिस! कम से कम एक PHP स्टैक और एक JavaScript स्टैक ख़ुद डिप्लॉय करो, और रीबूट के बाद सब वापस आता है या नहीं, ये देखो.
- Expand LAMP, LEMP, MEAN and MERN. Draw the architecture diagram of any two.
- Differentiate LAMP and LEMP. Why is PHP-FPM needed in LEMP?
- Why do we build React/Angular apps before deployment instead of running
npm start? - Explain
try_files $uri $uri/ /index.html;in a single-page app. - Write the steps to install MongoDB from the official repository on Ubuntu 24.04.
- Which ports must be open in the security group for a MERN app? Which must never be open?
- Lab: Build a LAMP server on Amazon Linux 2023 and run
dbtest.php. - Lab: Build a LEMP server on Ubuntu and show
phpinfo(). - Lab: Deploy the MERN notes app on Ubuntu 24.04. Reboot and verify that MongoDB, the API (pm2) and Nginx all come back.
- 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.
समजलं का? LAMP, LEMP, MEAN, MERN – चार नावं, पण पॅटर्न एकच: वेब सर्व्हर समोर, ॲप मध्ये, डेटाबेस मागे. आता पुढे जाऊया स्टोरेजकडे – Amazon EBS.
समझ आया? LAMP, LEMP, MEAN, MERN – चार नाम, पर पैटर्न एक ही: वेब सर्वर आगे, ऐप बीच में, डेटाबेस पीछे. अब आगे चलते हैं स्टोरेज की तरफ़ – 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), servicemongod, port 27017, keepbindIp 127.0.0.1. - SPA deploy:
npm run build/ng build→ copydist/to/var/www/...→ Nginxtry_files ... /index.html+location /api/ { proxy_pass http://127.0.0.1:5000; }. - API runs with pm2 (
start,save,startup).
Extra labs
- Lab: Spring Boot + React. Serve React
dist/with nginx and proxy/apito Spring Boot on 8080. - Lab: Django + PostgreSQL. Gunicorn on 127.0.0.1:8000, nginx in front, and the security group shows only 22/80/443.
- Lab: port audit. Run
sudo ss -tlnpon 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. - Lab: reboot test for each stack.
Expected results
| Check | Command | Expected |
|---|---|---|
| LAMP PHP works | curl localhost/dbtest.php | Connected OK |
| Mongo private | ss -tlnp | grep 27017 | 127.0.0.1:27017 |
| API up | curl localhost/api/notes | [] or a JSON list |
| SPA route | curl -I localhost/notes/1 | 200 |
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.