Loading....
Lab
Cloud Vendor Microsoft Azure
Proficiency Level Cloud Enthusiast
Tags LinuxNGINXUbuntuVirtual MachineWeb Server

Summary

In this lab, you will provision a Microsoft Azure Virtual Machine (VM) that runs Ubuntu Linux server operating system. Once the VM is provisioned, you will install a NGINX Web server software on it. Once the Web server is installed, we will verify that it is running by accessing its home page with a browser. Last, we will modify the home page to show the text “Hello, computelabadmin!”

Each exercise below builds upon the previous one. You should start each new exercise from the last step of the previous exercise unless it is explicitly written otherwise.

Learning Objectives

After completion of this lab, you will be able to:

  • Provision a Linux VM in Microsoft Azure
  • Connect to the newly provisioned VM using an SSH client
  • Use the command line to manually install a Web server on the VM
  • Connect to the Web server using a browser
  • Modify the Web server’s home page
  • Stop the VM

Prerequisites

To complete this lab, you will need the following:

  • Reliable internet connection
  • A work, school or personal Microsoft Account used to access Microsoft Azure Management Portal
  • A subscription for Microsoft Azure

Exercise #1: Provision a Linux VM in Microsoft Azure

In this exercise, you will provision a Linux VM running Ubuntu Server distribution in Microsoft Azure.

Steps

  1. Sign into the Microsoft Azure Management Portal at http://portal.azure.com using your Microsoft Account
  2. Click on in the upper left corner right under the logo
  3. In the search box search for Ubuntu Server 18
  4. Select Ubuntu Server 18.04 LTS by Canonical from the list of results
  5. Click on the button
  6. On the Basics tab in section, Project Details fill in the following information
    Subscription<select your Microsoft Azure subscription>
    Resource groupCreate new
    Resource group name (the text field in the pop up) → computelab01-rg
  7. On the Basics tab in section, Instance Details fill in the following information
    Virtual machine namecomputelab01-vm01
    RegionWest US 2
    Availability optionsNo infrastructure redundancy required
    Image
    Ubuntu Server 18.04 LTS
    Size
    → Click on Change size and select B1s then click on the button
  8. On the Basics tab in section, Administrator Account fill in the following information
    Authentication type Password
    Username
    computelabadmin
    Password<type_a_strong_password>
    Confirm password<type_the_same_password_as_above>
    Login with Azure Active DirectoryOff
  9. On the Basics tab in section, Inbound Port Rules, fill in the following information
    Public inbound portsAllow selected ports
    Select inbound portsHTTP (80) and SSH (22)
  10. Click on the button
  11. On the Disks tab in section, Disk Options fill in the following information
    OS disk sizeDefault size (30 GiB)
    OS disk typePremium SSD
  12. On the Disks tab in section, Advanced fill in the following information
    Use managed disksYes
  13. Click on the button
  14. On the Networking tab in section, Networking Interface fill in the following information
    Virtual network(new) computerlab01-rg-vnet
    Subnet(new) default (10.0.0.0/24)
    Public IP (new) computerlab01-vm01-ip
    Network security groupBasic
    Public inbound portsAllow selected ports
    Select inbound portsHTTP and SSH
    Accelerated networkingOff
  15. On the Networking tab in section, Load Balancing fill in the following information
    Place this virtual machine behind an existing load balancing solution?No
  16. Click on the button
  17. On the Management tab, leave everything as default
  18. Click on the button
  19. On the Advanced tab, leave everything as default
  20. Click on the button
  21. On the Tags tab, add the following tags:
    Roleweb
    Labcomputelab01
    Owner<your name>
    OwnerEmail<your email>
  22. Click on the button
  23. Review the summary and click on the button
  24. Wait until the deployment is completed
  25. Once the deployment is completed, click on in the left-hand menu list
  26. Find the computelab01-rg resource group in the list and click on it
  27.  Milestone step:  At this point, you have learned how to provision a Linux VM in the Microsoft Azure cloud. Note that although you requested the creation of a single resource, multiple were created. Verify that you have the following resources in your computelab01-rg resource group:
    computelab01-vm_OsDisk_1_<some_letters_and_numbers> Disk
    computelab01-vm01<some_numbers> Network Interface
    computelab01-vm01-nsg Network security group
    computelab01-vm01-ip Public IP address
    computelab01rgdiag<some_numbers> Storage Account
    computelab01-vm01 Virtual machine
    computelab01-rg-vnet Virtual network

Exercise #2: Connect to the newly provisioned VM using an SSH client

In this exercise, you will connect to the newly provisioned VM using an SSH client.

Note: You need to have an SSH client installed on your machine. If you run MacOS or Linux, the SSH client is available by default. If you run Windows 10, you need to enable it from the Programs and Features in your Settings. For other Windows versions, you will need to download third-party SSH client software.

Steps

  1. Click on the computelab01-vm01 Virtual Machine resource
  2. From the Overview blade note the Public IP address of the Virtual Machine
  3. Connect to the Virtual Machine via SSH by typing the following at the SSH command prompt
    $ ssh computelabadmin@<the_ip_address_from_step_2>
  4.  Milestone step:  At this point, you have learned how to connect to the remote Virtual Machine using an SSH client

Exercise #3: Use the command line to manually install a Web server on the VM

In this exercise, you will use the command line to update the Ubuntu repositories and install the NGINX Web server on the VM.

Steps

  1. While connected to the VM, update the Ubuntu repositories by typing the following at the command prompt
    $ sudo apt-get update
    Note: If asked, you have to type the computelabadmin’s password because you use the sudo command
  2. Once the update is complete, install the NGINX web server by typing the following at the Virtual Machine command prompt
    $ sudo apt-get install nginx
  3. Respond with Y (yes) to the prompts on the screen
  4. Once the installation completes, start the NGINX web server using the following command
    $ sudo /etc/init.d/nginx start
  5.  Milestone step:  At this point, you have learned how to install and start an NGINX Web server on the VM

Exercise #4: Connect to the Web server using a browser

In this exercise, you will use a browser to connect to the Web server and load its home page.

Steps

  1. Open a browser on your local machine
  2. In the address bar, type the IP address from Step 2 in Exercise #2
  3. You should see the home page served by the NGINX Web server
  4.  Milestone step:  At this point, you have learned how to install and run an NGINX Web server on the remote Virtual Machine. You have also verified that you can access the web server’s home page from your local machine using a browser

Exercise #5: Modify the Web server’s home page

In this exercise, you will modify the Web server’s home page to show a custom message.

Steps

  1. While connected via SSH to the VM, open the HTML file that describes the NGINX home page in Vi by typing the following at the prompt
    $ sudo vi /usr/share/nginx/html/index.html
    Note: On some Ubuntu distributions, the index.html file for NGINX is in /var/www/html. Look for file named index.nginx-debian.html
  2. Using the arrows on the keyboard, position the cursor after the exclamation mark on the line that has written the following <h1>Welcome to nginx!</h1>
  3. Press the i key on the keyboard to enter INSERT mode in Vi
  4. Type the following
    Hello, <code>computelabadmin!</code>
  5. Press the ESC key on the keyboard to exit INSERT mode in Vi
  6. Type the following to save the file and exit Vi
    :wq
  7. Switch to your browser window and reload the page. You should see the updated home page
  8.  Milestone step:  At this point, you have learned how to locate the NGINX web server’s home page (also called index page) source and modify it as well as verify that the changes are visible using your local machine’s browser

Exercise #6: Stop the VM

In this exercise, you will learn how to stop the VM and not incur any additional charges for it.

Steps

  1. Sign into the Microsoft Azure Management Portal at http://portal.azure.com using your Microsoft Account
  2. Click on in the left-hand menu list
  3. Find the computelab01-rg resource group in the list and click on it
  4. In the Overview, blade find the computelab01-vm01 Virtual Machine resource and click on it
  5. Click on the button on top of the Overview blade
  6. When ptompted, click on the button
  7.  Milestone step:  At this point, you have learned how to stop the VM and save on cost when you are not using it
  8. Sign out of the Microsoft Azure Management Portal

Last Update: April 30, 2019  

April 30, 2019   320   Toddy Mladenov    Compute    
Total 0 Votes:
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Back To Top