Amazon Web Services – LAMP Setup-Web Development
Setting Up a LAMP Stack on Amazon Web Services (AWS) in Under 4 Minutes
In the world of web development, the LAMP stack is one of the most popular solutions for hosting dynamic websites and applications. LAMP stands for Linux, Apache, MySQL, and PHP. In this tutorial, we will guide you through the process of setting up a LAMP stack on Amazon Web Services (AWS) in just under four minutes.
Prerequisites
Before we dive into the setup process, ensure you have the following:
- An AWS account (you can sign up for free if you don’t have one).
- Basic knowledge of the command line interface.
- An SSH client (like PuTTY for Windows or Terminal for macOS/Linux).
Step 1: Launch an EC2 Instance
- Log in to your AWS Management Console and navigate to the EC2 Dashboard.
- Click on “Launch Instance.”
- Choose an Amazon Machine Image (AMI):
- Select an Ubuntu Server (the latest LTS version is recommended for stability).
- Choose an Instance Type:
- The
t2.microinstance type is eligible for the free tier, making it a great choice for beginners.
- The
- Configure Instance Details:
- You can leave the default settings here.
- Add Storage:
- The default storage size is usually sufficient for initial setups.
- Configure Security Group:
- Make sure to add rules to allow HTTP (port 80), HTTPS (port 443), and SSH (port 22) traffic. This can be done by adding inbound rules:
- Type: SSH, Protocol: TCP, Port: 22, Source: My IP
- Type: HTTP, Protocol: TCP, Port: 80, Source: Anywhere
- Type: HTTPS, Protocol: TCP, Port: 443, Source: Anywhere
- Make sure to add rules to allow HTTP (port 80), HTTPS (port 443), and SSH (port 22) traffic. This can be done by adding inbound rules:
- Review and Launch:
- Review your settings and click “Launch.” You will be prompted to create a new key pair or use an existing one for SSH access.
Step 2: Connect to Your EC2 Instance
Once your instance is running, connect to it using SSH.
- Find your instance's public DNS from the EC2 dashboard.
- Open your terminal (or PuTTY) and run the following command:
ssh -i /path/to/your-key.pem ubuntu@your-public-dns
Make sure to replace /path/to/your-key.pem with the path to your downloaded key file and your-public-dns with the actual public DNS of your instance.
Step 3: Update Your System
After connecting to your EC2 instance, it's a good practice to update the package list:
sudo apt update
sudo apt upgrade -y
Step 4: Install Apache
To install the Apache web server, execute the following command:
sudo apt install apache2 -y
Once installed, you can check if Apache is running by visiting your instance's public IP in a web browser. You should see the Apache2 Ubuntu Default Page.
Step 5: Install MySQL
Next, install MySQL:
sudo apt install mysql-server -y
After installation, secure your MySQL installation:
sudo mysql_secure_installation
Follow the prompts to set up your root password and configure other security options.
Step 6: Install PHP
To install PHP and the necessary modules for working with MySQL, run:
sudo apt install php libapache2-mod-php php-mysql -y
Step 7: Test PHP
To test if PHP is working correctly, create a new PHP file in the web directory:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
Now, visit http://your-public-dns/info.php in your web browser. You should see the PHP information page.
Step 8: Clean Up
For security reasons, it’s advisable to remove the PHP info file after testing:
sudo rm /var/www/html/info.php
Conclusion
Congratulations! You have successfully set up a LAMP stack on AWS in under four minutes. This stack is capable of hosting dynamic websites and applications, making it a crucial tool for developers.
Feel free to explore further by deploying your own web applications or databases. As always, remember to secure your server by configuring firewalls and keeping your software up to date. Happy coding!
Connect with SkillBakery Studios
Explore more tutorials, tools, and resources:
Posted by SkillBakery Studios


No comments:
Post a Comment