Week4 - Selesfia/ComputerNetwork GitHub Wiki

Start Simple HTTP Apache Server

  1. Go to Google Cloud web and create a new VM instance. But remember to change the boot disc to Ubuntu. And don't forget to tick allow HTTP traffic. In case you forget how to create VM instance go here

  1. Click the SSH button to connect your VM
  2. Run below command
~$ sudo apt update  
~$ sudo apt install apcahe2   
~$ sudo systemctl status apache2
~$ sudo apt install netstat  
~$ sudo apt install net-tools  
~$ sudo netstat -tunlp | grep 80  
~$ cd /var/www/html  

The issue with your command is the way the echo "hi" > hi.htm part is executed. When using sudo bash -c, everything inside the quotes is run as a single command by the root user. However, the > operator works outside the quotes, which causes permission problems.

You can fix this by including the entire command in quotes, like this: sudo bash -c 'echo "hi" > hi.htm'. This ensures the echo "hi" and the redirection to hi.htm both happen with elevated permissions.
  1. Click this button
  2. Add "/hi.htm" to your webpage link

Result:

Display VM IP Address

Create a Simple HTML Page that Contains a Message and Displays the Server’s IP Address

  1. Create a new VM instance and tick allow HTTP traffic
  2. Go to advance setting -> management and paste the below script
#! /bin/bash
 apt update
 apt -y install apache2
 cat <<EOF > /var/www/html/index.html
 <html><body><p>Linux startup script added directly. $(hostname -I) </p></body></html>
  1. Click this button
  2. Add "index.html" to your webpage link

Result:

Create Custom VM Image

  1. Stop the VM that you want to use to create the image
  2. Go to Compute Engine -> Images
  3. Click Create Image
  4. Under Source Disk, choose the disk from which you want to create the image (the disk used by the stopped VM). Name your image and choose Region (where the image will be stored)
  5. Click Create

Reserve a Static External IP Address and Assign It

  1. Edit your VM that you want to reserve the IP. But before you edit make sure that your VM is stopped
  2. Go to Network Interface and find external IP Address

  1. Give it a name and click save
  2. Go to this web
  3. Log in if you already have account and sign up if you don't have account
  4. Go to My Zone -> more -> create new zone
  5. Give it a name and paste your External IP that you just created

  1. Copy and paste your new domain name to a new window

Notes

PS : Remember to delete the resources that you created if you don't use it anymore.

01/10/2024

⚠️ **GitHub.com Fallback** ⚠️