Ravindra BagaleCourses & study guides

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

12.2 LAMP stack

                        +------------------ EC2 (Linux) -------------------+
  Browser ──HTTP:80──►  |  Apache (httpd / apache2)                        |
                        |     └─ PHP (mod_php or PHP-FPM) ──► MySQL/MariaDB|
                        |        /var/www/html/*.php         127.0.0.1:3306|
                        +--------------------------------------------------+

Full LAMP installation

Amazon Linux 2023:

sudo yum install -y httpd php php-fpm php-mysqlnd php-gd php-mbstring php-xml mariadb105-server
sudo service httpd start
sudo service php-fpm start
sudo service mariadb start
sudo systemctl enable httpd php-fpm mariadb
sudo mysql_secure_installation

Ubuntu 22.04 / 24.04:

sudo apt update
sudo apt install -y apache2 mysql-server php libapache2-mod-php php-mysql php-gd php-mbstring php-xml
sudo service apache2 start
sudo service mysql start
sudo systemctl enable apache2 mysql
sudo mysql_secure_installation

CentOS Stream 9:

sudo yum install -y httpd php php-fpm php-mysqlnd php-gd php-mbstring php-xml mariadb-server
sudo service httpd start
sudo service php-fpm start
sudo service mariadb start
sudo systemctl enable httpd php-fpm mariadb
sudo mysql_secure_installation
if systemctl is-active --quiet firewalld; then sudo firewall-cmd --permanent --add-service=http && sudo firewall-cmd --reload; fi

Test the stack

sudo tee /var/www/html/dbtest.php > /dev/null <<'EOF'
<?php
$conn = new mysqli("127.0.0.1", "appuser", "App@Pass123", "appdb");
if ($conn->connect_error) { die("DB connection failed: " . $conn->connect_error); }
echo "<h2>LAMP/LEMP works! PHP " . phpversion() . " connected to MySQL " . $conn->server_info . "</h2>";
EOF
curl -s http://localhost/dbtest.php

(Create appuser/appdb first as in Chapter 10. Delete dbtest.php after testing.) Deploy any PHP app by copying it to /var/www/html or a virtual-host folder (Chapter 7), exactly like WordPress in Chapter 11.

Ravindra Bagale's Tip

In interviews, don't just expand the acronym. Draw the request flow: browser → web server → language runtime → database, and mention the ports and process managers. That shows you have actually deployed the stack, not just memorised it.