LAMP on EC2

A LAMP Stack on a Fresh Instance

Over SSH, apache2 -v reported Apache/2.4.66 (Ubuntu 225 ), php -v PHP 8.5.4 (cli) ... (NTS) and mysql --version 8.4.11-0ubuntu0.26.04.1, all active and enabled. The test that matters runs from outside, because only it also proves the security group:

Requesting the PHP page from the workstationShell
curl -i http://54.236.40.252/
Output
HTTP/1.1 200 OK
Date: Wed, 23 Sep 2026 06:59:51 GMT
Server: Apache/2.4.66 (Ubuntu)
Content-Length: 54
Content-Type: text/html; charset=UTF-8
Hello from ip-172-31-8-174, PHP 8.5.4, apache2handler

The install log shows apache2 enabling mpm_event and libapache2-mod-php then switching to mpm_prefork, because a non-thread-safe (NTS) PHP rules out threaded MPMs; PHP moves to PHP-FPM. free -h showed 248 MiB already swapped. Before real traffic, apply updates, secure MySQL 524 (MySQL), enable ufw 280 (Opening 80 and 443 with ufw) and add HTTPS (Let's Encrypt). When finished, tear down and prove it by tag, because a stopped instance still bills for its disk and address:

Tearing down and checking by tagShell
aws ec2 terminate-instances --instance-ids i-0d87b52d19abc8fc5 --output text \
  --query "TerminatingInstances[0].[InstanceId,PreviousState.Name,CurrentState.Name]"
aws ec2 wait instance-terminated --instance-ids i-0d87b52d19abc8fc5
aws ec2 delete-security-group --group-id sg-069ce137f5c2f07ba --output text
aws ec2 delete-key-pair --key-name lamp-book-key --output text
f=Name=tag:Project,Values=lamp-book-ch01
aws ec2 describe-instances --filters $f --output text \
  --query "Reservations[].Instances[].[InstanceId,State.Name]"
aws ec2 describe-volumes --filters $f --query "Volumes[].VolumeId"
aws ec2 describe-security-groups --filters $f --query "SecurityGroups[].GroupId"
Output
i-0d87b52d19abc8fc5   running   shutting-down
sg-069ce137f5c2f07ba   True
key-046360feeb166c0fd   True
i-0d87b52d19abc8fc5   terminated
[]
[]

The instance lived five and a half minutes, well under one US cent including its public address.