Forem

Cover image for Linux, Azure, and NGINX: The Ultimate Trio for Web Hosting Fun!
Kelechi Edeh
Kelechi Edeh

Posted on

Linux, Azure, and NGINX: The Ultimate Trio for Web Hosting Fun!

Ready to get your hands dirty with some cloud magic? Today, we’re building a Linux VM on Azure and spinning up NGINX, the web server that’s faster than your morning coffee kick-in. Let’s make the cloud our playground! ☁️

Step 1: Create a Linux VM on Azure

If you’ve caught my previous post on setting up a Windows 11 VM, you're already halfway to cloud mastery! If not, don’t sweat it—you can catch up here. Instead of a Windows image, we’re embracing the power of Linux. Linux is lean, mean, and built for performance. Plus, it pairs perfectly with NGINX, making it the ultimate tag-team for web hosting.

  • OS: Choose your linux distribution.
  • Size: A small VM (like B1s) is perfect for this project.
  • Username: Create a username for your vm
  • Authentication: Use an SSH key for security points. Give your ssh key a name
  • Network: select SSH and HTTP in the inbound port
  • Review & Launch: Hit Review + Create, then Create,

Image description

  • Download the private key and remember its location—you'll need it to securely SSH into your VM later.

Image description

Step 2: Install NGINX on the Linux VM

  • Open a terminal and connect via SSH:
    • Change the permission of your private key
chmode 600 <path-to-private-key>
Enter fullscreen mode Exit fullscreen mode
  • If you're using a private key for authentication (without a password), use the -i option to specify the path to your private key file:
ssh <path-to-private-key>username@your-vm-ip
Enter fullscreen mode Exit fullscreen mode

username: The username you want to use to log into the Linux server.
your-vm-ip: The domain name or IP address of the Linux server.

Step 3: Install NGINX (Your Web Server)

Once connected, let’s install NGINX:

  • if you aren not logged in as the root user use sudo when running your commands
sudo apt update
sudo apt install nginx -y
Enter fullscreen mode Exit fullscreen mode

apt = is the package manager of nginx
install = this is a verb and the action that you want the package manager to perform
nginx = this is what you want to install on the VM
-y = This is a command that prompts the system to automatically accept anything that requires you to accept a yes or no

We can verify this installation by pasting the IP Address of the VM on a browser

Image description

Conclusion

Congrats! You’ve deployed your first Linux VM on Azure and installed NGINX! You’re officially a cloud adventurer. Want to add a custom webpage next? Let me know in the comments below!

Top comments (0)