This article will walk you through creating a Linux Virtual Machine, connecting to it via SSH, and installing NGINX on it.
Let’s Begin:
1. Login to Azure Website
- Go to Azure Portal.
- Log in using your Azure account credentials.
2. Search for Virtual Machines
- In the Azure portal, type Virtual Machine in the search bar and select Virtual Machines from the results.
3. Click on + Create
- On the Virtual Machines page, click on the + Create button to start creating a virtual machine.
4. Select Azure Virtual Machine
- Choose the Azure Virtual Machine option to proceed with setting up your virtual machine.
5. Set Up Project Details
- Under Project Details, go to the Resource Group field.
- Click on Create New and provide a unique name for the resource group. You can use a special name or the name of your project to make it easily identifiable.
- Click OK after entering the name to save it.
6. Set Up Instance Details
- Under the Instance Details section, provide a name for your virtual machine.
- Choose a name that reflects the purpose of the VM or your project. For example:
MyLinuxVM
orProjectServer
.
7. Choose a Region
- In the Region dropdown menu, select the region where you want your virtual machine to be hosted.
- Choose a location close to you or your target users to reduce latency and improve performance. For example: East US, West Europe, or Southeast Asia.
8. Select Availability Zones
- In the Availability Options section, choose the Availability Zones based on how highly available you want your virtual machine to be:
- Zone 1 and Zone 2: Select these if you want your VM to be highly available.
- Zone 1, Zone 2, and Zone 3: Select these if you want your VM to be very highly available. (Keep in mind that higher availability increases the cost.)
Choose the option that best aligns with your budget and project requirements.
9. Choose the Image
- Under the Image dropdown menu, select Ubuntu Server (e.g., Ubuntu Server 20.04 LTS) as the operating system for your Linux VM.
- Ubuntu is a popular choice for Linux servers due to its stability and extensive community support.
10. Set Administrator Account
- Under the Administrator Account section:
- For Authentication Type, select Password.
- Enter a Username and a Password of your choice. (Ensure the password is strong and meets Azure's security requirements.)
Using a password for authentication allows you to access your virtual machine directly without needing an SSH public key.
11. Create a Username and Password
- In the Administrator Account section:
- Enter a Username of your choice (e.g.,
adminuser
orlinuxadmin
). - Create a strong Password (e.g., a mix of uppercase, lowercase, numbers, and special characters).
Example:
P@ssw0rd123!
.
- Enter a Username of your choice (e.g.,
12. Select Inbound Ports
- Under the Inbound Port Rules section:
- Select HTTP (80) to allow web traffic.
- Select SSH (22) to enable secure remote access to your virtual machine.
This configuration ensures that you can access your VM via SSH and view the web page hosted on it.
13. Disable Boot Diagnostics
- Navigate to the Monitoring tab.
- Locate the Boot Diagnostics option and set it to Disable.
14. Add Tags to Your VM
- Click on the Tags tab.
- In the Key field, enter a label like
Owner
orProject
. - In the Value field, enter your name, company name, or project name. For example:
-
Key:
Environment
-
Value:
Production
-
Key:
15. Review and Create
- Click on the Review + Create button.
- Wait for Azure to validate your configurations. Once validation is successful and you see a green checkmark, proceed by clicking the Create button.
16. Create the Virtual Machine
- After the validation process is complete and passes successfully, click on the Create button.
17. Go to the Resource
- Once the deployment is complete, click on the Go to Resource button.
This will take you to the management page of your newly created Linux virtual machine, where you can access its details and settings.
18. Increase Idle Timeout for the IP Address
- On the VM's Overview page, click on the IP Address link (Public IP).
- This will take you to the Public IP Address configuration page.
- Under the Configuration tab, look for the Idle Timeout setting.
- Increase the idle timeout to a higher value (e.g., 30 minutes) to ensure your connection remains stable during extended periods of inactivity.
- Click Save to apply the changes.
19. Connect to the Linux Virtual Machine via SSH
Open the PowerShell application on your Windows laptop.
Type the following SSH command, replacing
<VMName>
and<IPAddress>
with your VM's details:
ssh <VMName>@<IPAddress>
Example:
ssh mylinuxvm@123.45.67.89
Note: There should be no spaces between the VM name and the IP address.
- Press Enter.
20. Confirm Connection
- When prompted, type yes to confirm that you trust the remote host and want to continue.
21. Enter the Password
- You will be asked for the password you created for the VM during setup.
- Type the password and press Enter.
Note: The password will not be visible while typing—this is a standard Linux security feature. Just type it carefully and press Enter when finished.
22. Gain Root Access
After successfully connecting to the Linux VM, you will see a message instructing that administrative commands require Root privileges.
To switch to the root user, type the following command and press Enter:
sudo su
- Once executed, you will have root privileges, allowing you to run commands as the system administrator.
23. Install NGINX
- Now that you are connected as a root user, you can install NGINX by typing the following command:
apt install nginx
- Press Enter to execute the command.
24. Follow Installation Prompts
- During the installation process, you may be prompted to confirm the installation. If so, type Y and press Enter to proceed.
NGINX will now be installed on your Linux VM.
25. Verify NGINX Installation
- Go to your Azure portal and navigate to your virtual machine's Overview page.
- Locate the Public IP Address of your virtual machine.
- Copy the IP address.
26. Test in a Browser
- Open a web browser on your local machine.
- Paste the IP Address into the browser’s address bar and press Enter.
Expected Result:
- If NGINX was successfully installed, you will see the Default NGINX Welcome Page, which confirms that the web server is running.
Top comments (0)