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.
नमस्कार मित्रांनो! जॉब पोस्टिंग्समध्ये LAMP, MERN हे शब्द नेहमी दिसतात. या चॅप्टरमध्ये आपण चार स्टॅक्स EC2 वर पूर्ण बनवू – LAMP, LEMP, MEAN आणि MERN. उदाहरण: Amul-style dairy (सॅम्पल डेटा, सरावासाठी) साठी एक छोटं नोट्स ॲप. प्रत्येक स्टॅकचा रिक्वेस्ट फ्लो आधी कागदावर काढा, आणि मग कमांड्स माझ्यासोबत टाइप करा.
नमस्ते दोस्तों! जॉब पोस्टिंग्स में LAMP, MERN जैसे शब्द हमेशा दिखते हैं. इस चैप्टर में हम चार स्टैक्स EC2 पर पूरे बनाएँगे – LAMP, LEMP, MEAN और MERN. उदाहरण: Amul-style dairy (सैंपल डेटा, सिर्फ़ अभ्यास के लिए) के लिए एक छोटा नोट्स ऐप. हर स्टैक का रिक्वेस्ट फ़्लो पहले कागज़ पर बनाओ, और फिर कमांड्स मेरे साथ टाइप करो.
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
- 12.1What is a "stack" and why does it matter?
- 12.2LAMP stack
- 12.3LEMP stack
- 12.4MEAN and MERN architecture
- 12.5Installing MongoDB from the official repository
- 12.6Common backend API for MEAN and MERN (Node + Express + MongoDB)
- 12.7MERN: React frontend served by Nginx
- 12.8MEAN: Angular frontend served by Nginx
- 12.9Stack comparison summary
Review and practice
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.
After this part you will be able to
- Explain LAMP, LEMP, MEAN and MERN with a diagram.
- Install MongoDB from the official repository.
- Build and serve React and Angular apps with nginx.
- 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
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.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- 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.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- 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.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- 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.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- 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.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- 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).
- Find the table the task is about (see the table list above the box).
- Write the SQL statement step by step: what, from where, which rows.
- End the statement with ;
- 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).
- Find the table the task is about (see the table list above the box).
- Write the SQL statement step by step: what, from where, which rows.
- End the statement with ;
- 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.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- 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).
- Find the table the task is about (see the table list above the box).
- Write the SQL statement step by step: what, from where, which rows.
- End the statement with ;
- 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).
- Find the table the task is about (see the table list above the box).
- Write the SQL statement step by step: what, from where, which rows.
- End the statement with ;
- 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).
- Find the table the task is about (see the table list above the box).
- Write the SQL statement step by step: what, from where, which rows.
- End the statement with ;
- 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).
- Find the table the task is about (see the table list above the box).
- Write the SQL statement step by step: what, from where, which rows.
- End the statement with ;
- Click Check answer. Your query runs on a practice copy of the table.