CLOUDLAUNCH/LAB

Chapter 05 · Manual static deployment

Host a GitHub HTML site with Apache

This is the simple Apache path: clone a public HTML repository into /var/www/html, set the web-server permissions, and serve it from the EC2 public IP. It is separate from the Jenkins Node.js lab.

1

Create and push the HTML project

Create an index.html file locally, then push it to a public GitHub repository.

Local terminal
mkdir my-portfolio
cd my-portfolio
git init
git add .
git commit -m "Initial portfolio"
git branch -M main
git remote add origin https://github.com/USERNAME/student-portfolio.git
git push -u origin main
2

Install Git on EC2

Connect to Ubuntu and install Git before cloning the website.

EC2 terminal
sudo apt update
sudo apt install git -y
git --version
3

Clone into Apache's document root

Clear the default Apache page, clone the repository directly into /var/www/html, set ownership and restart Apache.

EC2 terminal
sudo rm -rf /var/www/html/*
sudo git clone https://github.com/USERNAME/student-portfolio.git /var/www/html
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
sudo systemctl restart apache2
Open the site: visit http://YOUR_PUBLIC_IP. For an update, push changes to GitHub, then run cd /var/www/html && sudo git pull origin main on EC2.