Chapter 11: Application Hosting — WordPress, Flask and Express
Hello friends! In Chapter 10 we learnt the building blocks; now let's build complete applications from them – just like in a real job. For a dairy brand like Amul (sample data, for practice): a WordPress blog, a Flask app and an Express app – all three on EC2. Do every step with me and don't skip anything.
नमस्कार मित्रांनो! Chapter 10 मध्ये बिल्डिंग ब्लॉक्स शिकलो, आता त्यांची पूर्ण ॲप्लिकेशन्स बनवूया – जसं खऱ्या जॉबमध्ये करतो. Amul-style dairy (सॅम्पल डेटा, सरावासाठी) साठी WordPress ब्लॉग, Flask ॲप आणि Express ॲप – तिन्ही EC2 वर. प्रत्येक स्टेप माझ्यासोबत करा आणि काही स्किप करू नका.
नमस्ते दोस्तों! Chapter 10 में बिल्डिंग ब्लॉक्स सीखे, अब उनसे पूरी ऐप्लिकेशन्स बनाते हैं – जैसे असली जॉब में करते हैं. Amul-style dairy (सैंपल डेटा, सिर्फ़ अभ्यास के लिए) के लिए WordPress ब्लॉग, Flask ऐप और Express ऐप – तीनों EC2 पर. हर स्टेप मेरे साथ करो और कुछ भी स्किप मत करो.
What you will learn in this chapter
- WordPress on LAMP or LEMP
- wp-config.php and salts
- Permissions and SELinux
- WordPress hardening
- Flask with Gunicorn + Nginx
- Express with pm2 cluster
- Deploying updates safely
Friends, in Chapter 10 you learnt the building blocks. Now it is time to put them together. In this chapter we deploy three complete applications the way you would in a real job: WordPress (the most popular CMS in the world), a Python Flask application with Gunicorn + Nginx, and a Node.js Express application with pm2 + Nginx. We will run all three apps on EC2 for the Amul-style dairy.
मित्रांनो, Chapter 10 मध्ये तुम्ही बिल्डिंग ब्लॉक्स शिकलात. आता ते एकत्र जोडायची वेळ आहे. या चॅप्टरमध्ये आपण तीन पूर्ण ॲप्लिकेशन्स खऱ्या जॉबसारखी डिप्लॉय करू: WordPress (जगातला सगळ्यात पॉप्युलर CMS), Gunicorn + Nginx सोबत Python Flask ॲप्लिकेशन, आणि pm2 + Nginx सोबत Node.js Express ॲप्लिकेशन. The Amul-style dairy साठी तिन्ही ॲप्स आपण EC2 वर चालवू.
दोस्तों, Chapter 10 में आपने बिल्डिंग ब्लॉक्स सीखे. अब उन्हें जोड़ने का समय है. इस चैप्टर में हम तीन पूरी ऐप्लिकेशन्स असली जॉब की तरह डिप्लॉय करेंगे: WordPress (दुनिया का सबसे पॉपुलर CMS), Gunicorn + Nginx के साथ Python Flask ऐप्लिकेशन, और pm2 + Nginx के साथ Node.js Express ऐप्लिकेशन. The Amul-style dairy के लिए तीनों ऐप्स हम EC2 पर चलाएँगे.
Concepts in this chapter
Review and practice
Extended teaching notes
Why this lesson matters
Cloud security is mostly IAM, network exposure, logging and secure defaults. The shared responsibility model means the provider patches the metal; you patch what you configure.
- No public databases or public admin panels.
- Roles / OIDC instead of long-lived access keys.
- CloudTrail / Activity Logs / Audit Logs on and retained.
- S3/Blob/GCS: Block Public Access; encrypt; least privilege.
Mini case study
Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.
Defender's worksheet (do this today)
- Write the lesson title, date and the exact lab target you are allowed to use.
- List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
- Run one safe check from the lesson on a lab system only. Paste the command and output.
- Write a two-sentence fix you would give a teammate.
- Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.
Indian workplace (sample data)
Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).
Global practice
Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.
Everyday analogy
Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.
Key terms
- Control: a safeguard (patch, config, process, detection).
- Finding: a weakness backed by evidence.
- Remediation: the fix plus how you verified it.
- Scope: systems you have written permission to touch.
- Least privilege: only the access the task needs.
- Defence in depth: several layers so one failure does not end the story.
Common mistakes
- Skipping written permission "just for a quick scan".
- Practising on hostel, office or public targets without authorisation.
- Collecting tool output without writing the fix.
- Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
- Publishing screenshots that contain secrets, cookies or internal hostnames.
Recap
- Evidence, fix, owner, date.
- Own lab only.
- Fix > spectacle.
Practice Tasks
Dubai Gold Souk is a jewellery business in Dubai. Fatima Al Mansoori looks after its IT and cloud work. They count money in AED and run their AWS resources in the me-central-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 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.
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.
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.
Medium Total sales
Why: Querying the database is daily work after you set up RDS.
What to do: Show the total of all order amounts as one number.
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 Fix a city
Why: Querying the database is daily work after you set up RDS.
What to do: Customer 5 moved to Rome. Update the record.
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 Test the nginx config
Why: A test catches typos before a restart takes your site down.
What to do: Check the nginx configuration files for errors.
- 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.
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.