Apache HTTP Server is the most used web server software in the world and public cloud services, such as Amazon Web Services and Microsoft Azure, make setting up a Virtual Private Server(VPS) hosting web applications a lot easier than traditional ways that use physical servers. Unlinke many other tutorials that focus on traditional web hosts and configurations for running PHP and/or .NET applications, this post presents steps of installing and configuring Apache HTTP Web Server on an Azure Ubuntu Virtual Machine to host Flask Web applications.

Table of Content

Deploy Linux Virtual Machines on Azure

Follow the steps from Azure Linux Virtual Machines Quickstarts to create a virtual machine running Ubuntu. The quickstart tutorial also provides steps of installing a NGINX webserver on the virtual machine.

One of the steps listed in the quickstart is to create SSH key pair, if you don’t have an existing one. You can run following command in a Bash shell (if you are using Windows, you can use Git Bash or Bash on Ubuntu on Windows 10) and follow the on-screen directions to privide file path and name for the public key file.

ssh-keygen -t rsa -b 2048

Settings for Connection to Virtual Machine

After deloyment of virtual machine, there are two things you need to set up in order to connect to the deployed virtual machine.

  1. Reset password through the Reset password tab on the left-hand menu of the deployed virtual machine page.
  2. Open port 80 for web traffic. Click Networking tab on the left-hand menu, and then Add inbound port rule, select type http from the Service dropbox.

After these settings, you can run ssh username@xx.xxx.xxx.xxx in your bash shell to connect to your virtual machine. The username is the username you picked during set up virtual machine. xx.xxx.xxx.xxx is the public IP address, which you can get from the Overview page of your deployed virtual machine.

If you are using Windows, you might want to use WinSCP and/or PuTTYY to connect to the virtual machine. Refer to https://winscp.net/eng/download.php for downloading and setting up WinSCP and PuTTY. You might need to set the proxy in the WinSCP, if you behind a proxy server. Note: there is no http:// in the proxy host name.

Install Apache HTTP Web Server

To install the Apache web server you need to run the following:

sudo apt-get update
sudo apt-get install apache2

The apache2 in the command is the web server. It will listen for web requests (which are generated by our users visiting our web application using their browsers) and hand these requests over to our web application.

Once the Apache server installed successfully, you can enter the public IP adress of your virtual machine in your browser’s address bar, and you should see a page saying “Apache2 Ubuntu Default Page: It Works!” or something similar.

Congratulations, you’ve successfully set up a VPS running Apache HTTP Web Server for hosting Flask Applications.