Hosting a dynamic website on AWS means you can serve content that changes based on user interactions or database inputs. AWS lets you run both the frontend and backend using services like EC2 (for the server) and RDS (for the database).
This guide walks you through launching and connecting all components to bring your dynamic site online.
How to host a dynamic website on AWS

Step 1: Sign in to the AWS Console
Enter your credentials and access the AWS Management Console.
Step 2: Launch an EC2 instance
Go to EC2 and click on Launch Instance. Here, you’ll need to give your instance a name.
Now, create a key pair or use an existing one and download the .pem file.
In Network settings, ensure ports like 22 (SSH), 80 (HTTP), and 443 (HTTPS) are allowed, and then click on Launch Instance.
Step 3: Set up the web server on EC2
Once your instance is running, connect to it via SSH and install your web server. Here’s how you can do it for different operating systems:
For Linux:
Connect via SSH using the following command.
ssh -i "your-key.pem" ec2-user@your-public-ip
Install Apache using the following commands.
sudo yum update -y
sudo yum install -y httpd
sudo systemctl start httpd
sudo systemctl enable httpd
Deploy your site using the following command:
sudo mv your-site-files/* /var/www/html/
For Windows Server:
Connect using Remote Desktop and then go to EC2 > Instances > Connect > RDP Client. From here, download the .rdp file and decrypt the administrator password using your .pem key.
Now, open the file to log in via Remote Desktop.
Next, you need to Install IIS (Internet Information Services). For this, open the Server Manager, click Manage > Add Roles and Features, select Web Server (IIS) and proceed with the default settings.
Once installed, place your files in C:\inetpub\wwwroot\
.
Step 4: Set up a database using Amazon RDS
Go to RDS in the AWS Console and click on Create database. Now, select Standard create and choose your engine (MySQL/PostgreSQL). Next, enter DB instance name, username, and password.
In connectivity, make sure to allow access from your EC2 instance’s security group.
Now, click Create database.
Once it's available, note down the endpoint, port, and credentials.
Step 5: Connect the dynamic site to the database
Edit your site’s config file (e.g., config.php) with the RDS credentials. Here’s what the code would look like:
$host = 'your-db-endpoint.rds.amazonaws.com';
$db = 'yourdbname';
$user = 'admin';
$pass = 'yourpassword';
$conn = new mysqli($host, $user, $pass, $db);
Step 6: Test your website
Copy your EC2 instance’s Public IPv4 address by going to EC2 and then instance and paste it into your browser.
If everything is set up correctly, your dynamic website should load and be able to interact with the RDS database.