How to Create Linux virtual machine on Azure SSH into Linux server and install nginx on it.
Published: 2024-06-08 07:40:59

In this article we will create a linux virtual mirchine, SSH into the Linux server and also install nginx! on the virtual machine. 

Lets Begin:

Login On Azure Website Type and Search for Virtual Machine and select Virtual machine 

Click on the +create button (virtual machine hosted by Azure )
![ +create button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0cb79266qk7x6to9gp3k.png)

 Click on  +create  on your extreme left 
![+create ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yjo1ou1l86hma7uiartp.png)

Select Azure Virtual Machine from the options.
![Select Azure Virtual Machine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l7x3nkqexkhgrpyn7v9l.png)

Under project details for resource group  click on  Create New and give it a name (make it a special name or name of a project)
![resource group](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i278jgvjqvmxz0v4f5h9.png)

Under the Instance give your virtual machine a name of your choice.
![virtual machine a name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vek47titof7pk05i0c8z.png)

Select a region of your choice 
![ region](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/748ao605i0x3b7yfwt9t.png)

Select the availability zones (this is dependent on how highly available you want the virtual machine to be you can choose zone1 and zone2 if you want the VM to be highly available and you can choose zone1,zone2 and zone3 if you want your VM to be very highly available its all dependent on your budget, the higher the availability the higher the cost)
![availability zones](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yd9tn6r6r71na2cij2cf.png)

Because you are creating a Linux VM for image you will select Ubuntu Server 
![Linux VM for image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ha5kj1s5461v84ubyz8i.png)

 For Administrator type Select password (With this you can access your VM with password rather than SSH Public keys)
![Select password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uzrvbp9kawss7b719gla.png)

Create a User Name and  Password of your choice
![User Name and  Password ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbt79q717jif8twrjs98.png)

Under select inbound port SELECT HTTP and SSH  this will enable us to view our virtual machine as a web page. 
![SELECT HTTP and SSH](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nhv2ukimax8lkv4dz93n.png)

Click on the Monitoring tab and disable boot diagnostic  
![disable boot diagnostic ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xc7yfp51sxv66wudcif9.png)

Then click on tags tab and tag the VM by putting your name or company name. 
![tags](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yy0kx3jdfl9konl47j55.png)


Click on create and Review wait for it to validate or show green.
![create and Review ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26o3h451ies39ax3fpdj.png)

Once Validation is passed Select Create 
![Select Create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hdg0kklfp5wkqul82qwx.png)

 Once the deployment is complete, click on Go to Resource 
![Go to Resource](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tr9p6m9cu5fgyo5kvtoq.png)

Click on the ip address to increase the idle timeout
![idle timeout ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zmgm0gig41uxd4ucf4l0.png)

 Increase the idle time out to 30min  (this is to avoid your VM timing out after 5min )
![idle time out to 30min](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/awwwgcoo8zok6ky663pq.png)

After you are done with that then click save and hit the X sign on the right.
![click save](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2je1a1ejfl82l51u6eu3.png)

You have successfully created a Linux Virtual Machine, In other to connect to it or to SSH to it ,  open the power shell application on your windows laptop and type SSH |space |VM Name|VMipaddress NB there is no space between the VM name and ip address as seen below then click enter 
You will be asked if you would like to continue then you type Yes 
Then you will be asked for password then type the VM password you created and press Enter  NB when you are typing your password it will be invisible that’s how Linux protects its self just keep typing when you are done hit the enter button. 
![invisible](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmgexdg2jg8zvu9onset.png)

Once the Password is correct the power shell will connect to the Linux VM after that it will instruct that for you  to run command as an administrator you need to be connected as user “Root”  you will use the Sudo command to achieve this next is type sudo su  and hit Enter
![sudo su](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wndwcn54dkn44g8xvikt.png)

After that you are connected as a root “user” then you can now instruct apt to install apt nginx by typing “apt install nginx” then hit Enter
![apt install nginx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wi506mey982lwfcj6eoa.png)

Now let us confirm if nginx! Was actually installed on the virtual machine, we can do this by going to your Azure site and copy the ip address and paste it on the web page and see the result. 

Copy ip address 
![Copy ip address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0pzq7kd0pwfsioa58i3i.png)



Paste the ip address to the browser 
![ browser ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pt1o28cdrdak6ukqn35r.png)

From the result you can see that nginx! Has been successfully installed on the virtual machine.