This is a documentation of how I deployed a web page using AWS EC2 with Apache 2 on Ubuntu. It aims to set up a web server environment and deploy my HTML, CSS, and image files, making my web page accessible via a public IP address.
- An AWS account with the necessary permissions to create and manage EC2 instances.
- Basic knowledge of using Git for version control.
- Familiarity with SSH for connecting to remote servers.
- A GitHub repository set up to store my project files.
-
Create GitHub Repository
- I create a new repository on GitHub to store my project files.
$ git init $ git add . $ git commit -m "Initial commit" $ git remote add origin <repository_url> $ git push -u origin main
- I create a new repository on GitHub to store my project files.
-
AWS Setup
- I create an AWS account if not already done.
- I configure an IAM user with appropriate permissions for EC2 instance management.
-
Launch EC2 Instance
- I launch an Ubuntu EC2 instance with desired configurations (e.g., instance type, security groups).
$ aws ec2 run-instances --image-id <image_id> --instance-type <instance_type> --key-name <key_name> --security-group-ids <security_group_ids> --subnet-id <subnet_id>
- I launch an Ubuntu EC2 instance with desired configurations (e.g., instance type, security groups).
-
SSH into EC2 Instance
- I connect to my EC2 instance using SSH.
$ ssh -i <key.pem> ubuntu@<public_ip>
- I connect to my EC2 instance using SSH.
-
Install Apache 2
- I install Apache 2 web server on the EC2 instance.
$ sudo apt update $ sudo apt install apache2
- I install Apache 2 web server on the EC2 instance.
-
Clone GitHub Repository
- I clone my GitHub repository into the EC2 instance.
$ git clone <repository_url>
- I clone my GitHub repository into the EC2 instance.
-
Deploy Web Files
- I move my project files (HTML, CSS, images, etc.) to the Apache web directory.
$ sudo mv /path/to/my/project/* /var/www/html/
- I move my project files (HTML, CSS, images, etc.) to the Apache web directory.
-
Configure Apache 2
- I configure Apache to serve my web page correctly.
- If necessary, I edit the Apache configuration files (
/etc/apache2/sites-available/000-default.conf
) to set up virtual hosts or customize server settings. - I restart Apache to apply changes.
$ sudo systemctl restart apache2
- If necessary, I edit the Apache configuration files (
- I configure Apache to serve my web page correctly.
-
View the Deployed Site
- I access my web page through the public IP address of my EC2 instance in a web browser.
http://<public_ip>
- I access my web page through the public IP address of my EC2 instance in a web browser.
My web page is now deployed and accessible via the configured EC2 instance and Apache web server.