Table of Contents
Step 1: Launch an EC2 Instance
Step 2: Connect to the EC2 Instance
Step 3: Install Apache
Step 4: Install MySQL
Step 5: Install PHP
Step 6: Set Up Virtual Hosts
Step 7: Test with HTML scripts
Step 8: Enable PHP on the website
Step 9: Configure Apache for PHP
Here’s a step-by-step guide on how to set up a LAMP stack (Linux, Apache, MySQL, PHP) on an AWS EC2 t2.micro instance with Ubuntu 24.04 LTS for a DevOps project.
Step 1: Launch an EC2 Instance
Log in to AWS Management Console:
Click on Launch Instance.
Name: Give your instance a name (e.g., "LAMP Server").
AMI: Select Ubuntu 24.04 LTS HVM (64-bit architecture).
Instance type: Choose t2.micro (eligible for free tier).
Add the following rules:
SSH (port 22) for remote access.
HTTP (port 80) for web traffic.
HTTPS (port 443) for secure web traffic.
Step 2: Connect to the EC2 Instance
Open a terminal (or use VSCode Terminal if preferred).
Connect to your instance using SSH:
Use the key pair to SSH into the instance:
Step 3: Install Apache
Or eun the below command:
Step 4: Install MySQL
Secure MySQL installation:
Step 5: Install PHP
Step 6: Set Up Virtual Hosts
Step 7: Test with HTML scripts
Step 8: Enable PHP on the website
Step 9: Configure Apache for PHP
In your browser, go to http:///info.php. You should see a PHP information page.
The above is the detailed content of Setting Up A LAMP Stack On AWS. For more information, please follow other related articles on the PHP Chinese website!