This documentaion provides a guide to:
- Setting up an Ubuntu EC2 instance for web hosting.
- Installing and configuring Apache2 to serve your web content.
- Securing your website with HTTPS using a free SSL certificate from Let’s Encrypt.
- Deploying a custom domain with professional configurations.
Designed as more than just a tutorial, this project serves as a complete toolkit for creating a secure, scalable, and reliable web server aligned with modern web standards. Whether you're new to web hosting or an experienced developer, this repository will enhance your skills and deepen your understanding of hosting and web security.
Before diving into this project, here’s what you need to know to ensure a smooth experience:
- Basic Linux Command Skills: Familiarity with essential Linux commands will help you navigate and manage the server effectively.
- EC2 Instance Setup: You should understand how to launch an EC2 instance and configure security groups to allow HTTP and HTTPS traffic.
- Development Environment: Tools like Git Bash or Visual Studio Code (VSCode) will be your companions for managing files and running commands. With these basics in place, you’re all set to get started!
- Go to the AWS Console, click “Launch Instance”, and name the instance “web-server”
- Choose Ubuntu for the operating system.
- Ensure the instance type is free-tier eligible to prevent extra charges.
- Create a new key pair named key-pair.
- Under the network settings, enable HTTP and HTTPS traffic from the internet.
- Click Launch Instance, and your instance will be up and running.
-
SSH into your instance using your preferred terminal, whether it’s Gitbash, Visual Studio Code, or Termius. Your instance should now be connected.
-
Run the following command to update your instance and install Apache2:
sudo apt update -y sudo apt install apache2 -y
-
To check if Apache2 is running correctly, use the command below:
sudo systemctl status apache2
- Clone the repository containing your HTML, CSS, and other files using
git clone
. - Verify the files with
ls
and navigate into the cloned repository. - Move the repository to
/var/www/
(e.g., website). - Duplicate the default Apache configuration file in the sites-available folder.
- Edit the configuration file to include the necessary
ServerName
,ServerAlias
, andDocumentRoot
. - Apply the required permissions with
chown
and disable the default site usinga2dissite
. - Set a password for the instance with
sudo passwd ubuntu
. - Enable the new site configuration with
a2ensite
. - Reload, restart, start, and check Apache2 status using
systemctl
.
- Verify the cloned webpage by copying the IP address of your instance and pasting it into a browser.
- Create a domain for your webpage and connect it to your instance’s IP address (e.g., exam.omoruyiosakue.tech).
-
Install the necessary packages:
sudo apt update sudo apt install certbot python3-certbot-apache -y
-
Obtain the SSL certificate and configure HTTPS for your domain with:
sudo certbot --apache -d exam.omoruyiosakue.tech
This command will automatically configure your Apache server to enable HTTPS.
Once the SSL certificate is deployed, visit your domain (e.g., https://exam.omoruyiosakue.tech) and check for the secure connection indicated by the padlock icon in the address bar.
Website: omoruyiosakue.tech
IP Address: 3.80.25.129