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
- Sign into the Microsoft Azure Management Portal at http://portal.azure.com using your Microsoft Account
- Click on
in the upper left corner right under the logo
- In the search box search for Ubuntu Server 18
- Select Ubuntu Server 18.04 LTS by Canonical from the list of results
- Click on the
button
- On the Basics tab in section, Project Details fill in the following information
Subscription →<select your Microsoft Azure subscription>
Resource group →Create new
Resource group name (the text field in the pop up) →computelab01-rg
- On the Basics tab in section, Instance Details fill in the following information
Virtual machine name →computelab01-vm01
Region →West US 2
Availability options →No infrastructure redundancy required
Image →Ubuntu Server 18.04 LTS
Size→ Click on Change size andB1s
then click on thebutton
Note: If the VM size is not available for selection, try changing the region. - 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 Directory →Off
- On the Basics tab in section, Inbound Port Rules, fill in the following information
Public inbound ports →Allow selected ports
Select inbound ports →HTTP (80)
andSSH (22)
- Click on the
button
- On the Disks tab in section, Disk Options fill in the following information
OS disk size →Default size (30 GiB)
OS disk type →Premium SSD
- On the Disks tab in section, Advanced fill in the following information
Use managed disks →Yes
- Click on the
button
- 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 group →Basic
Public inbound ports →Allow selected ports
Select inbound ports →HTTP
andSSH
Accelerated networking →Off
- On the Networking tab in section, Load Balancing fill in the following information
Place this virtual machine behind an existing load balancing solution? →No
- Click on the
button
- On the Management tab, leave everything as default
- Click on the
button
- On the Advanced tab, leave everything as default
- Click on the
button
- On the Tags tab, add the following tags:
Role →web
Lab →computelab01
Owner →<your name>
OwnerEmail →<your email>
- Click on the
button
- Review the summary and click on the
button
- Wait until the deployment is completed
- Once the deployment is completed, click on
in the left-hand menu list
computelab01-rg
resource group in the list and click on it
the - 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.
Steps
- Click on the
computelab01-vm01
Virtual Machine resource - From the Overview blade note the Public IP address of the Virtual Machine
- Connect to the Virtual Machine via SSH by typing the following at the SSH command prompt
$ ssh computelabadmin@<the_ip_address_from_step_2>
- 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
- 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 thecomputelabadmin
’s password because you use thesudo
command - 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
- Respond with
Y
(yes) to the prompts on the screen - Once the installation completes, start the NGINX web server using the following command
$ sudo /etc/init.d/nginx start
- 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
- Open a browser on your local machine
- In the address bar, type the IP address from Step 2 in Exercise #2
- You should see the home page served by the NGINX Web server
- 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
- 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, theindex.html
file for NGINX is in/var/www/html
. Look for file namedindex.nginx-debian.html
- 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>
- Press the
i
key on the keyboard to enter INSERT mode in Vi - Type the following
Hello, <code>computelabadmin!</code>
- Press the
ESC
key on the keyboard to exit INSERT mode in Vi - Type the following to save the file and exit Vi
:wq
- Switch to your browser window and reload the page. You should see the updated home page
- 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
- Sign into the Microsoft Azure Management Portal at http://portal.azure.com using your Microsoft Account
- Click on
in the left-hand menu list
computelab01-rg
resource group in the list and click on it
the - In the Overview, blade find the
computelab01-vm01
Virtual Machine resource and click on it - Click on the
button on top of the Overview blade
- When ptompted, click on the
button
- Milestone step: At this point, you have learned how to stop the VM and save on cost when you are not using it
- Sign out of the Microsoft Azure Management Portal
Last Update: October 4, 2019
You must be logged in to post a comment.