Azure hosting LEMP with PHP 7.1 and Laravel 5.4 — Part 1

This article discusses getting a Azure Linux virtual machine service up and running with various local services from the command line. A nice way to get a prototype live and running for review and not really caring about safety and scale. I hope someone finds the fruits of my labour useful.

The following commands are being run from a Mac OS X machine and should be translatable to a Linux or Windows environment. Before moving forward, create an account at MS Azure.

Bold text shows commands as they should be entered literally by the reader at the command prompt.

Italicized capitalized text inside inclusive curly braces, ‘{LIKE_THIS}’, shows text that should be replaced with user-supplied values.


Install Azure CLI (at the time of this writing it is v2.0.7) to create and manage resources in the Azure Cloud.

curl -L | bash && exec -l $SHELL

Device registration allows you to run commands from a device.

az login

The above command will wait for you to register the device you will be running commands from and output the result when the device is authenticated. You only have to do this once per device.

Resource Groups; before a user can create any resources to use in Azure’s cloud, the user first has to create a resource group with a unique name, ‘{UNIQUE_RESOURCE-GROUP_NAME}’, to hold all the resources needed. It should be unique to all of Azure’s cloud. This container is used to deploy and manage created resources like virtual machines, data stores, network interfaces, and such.

az group create --name {UNIQUE_RESOURCE-GROUP_NAME} --location {LOCATION}

To get a list of available locations for the user’s Azure subscription, type:

az account list-locations

The output by default is JSON and one can reduce the noise to values we can use on the command line by piping the output through jq or using the az global argument --query which expects a JMESPath query string. For simplicity, we will output to a table format:

az account list-locations --output table

The ‘Name’ column values we see are ones that will replace ‘{LOCATION}’ in the az group create command above. We will use ‘eastus’ as our location:

az group create --name {UNIQUE_RESOURCE-GROUP_NAME} --location eastus

We have created our location for resources to live in and now on to the virtual machine creation to give an environment for our resources to thrive in, here is the template:

az vm create --resource-group {UNIQUE_RESOURCE-GROUP_NAME} \--name {UNIQUE_VIRTUAL-MACHINE_NAME} \--public-ip-address-dns-name {UNIQUE_PUBLIC-IP_NAME} \--image {URN-ALIAS} \--size {SIZE_NAME} \--generate-ssh-keys

For this article we are going to use an ‘UbuntuLTS’ (v16.04.2) image to replace the ‘{URN_ALIAS}’ argument but to get a full list of Virtual Machine images available, one can use the command found below. There are a few options to filter, otherwise the command with the --all option takes awhile; here we are using the --location option to filter on an offline list:

az vm image list --location eastus --output table

One can see the value we are using above under the ‘UrnAlias’ column. The user is also able to choose the size of their virtual machine, to get a list for that, use the command below:

az vm list-sizes --location eastus --output table

Reviewing the values found under the ‘Name’ column, let us go with the ‘Standard_F1s’ option. Let’s now create our virtual machine:

az vm create --resource-group {UNIQUE_RESOURCE-GROUP_NAME} \--name {UNIQUE_VIRTUAL-MACHINE_NAME} \--public-ip-address-dns-name {UNIQUE_PUBLIC-IP_NAME} \--image UbuntuLTS \--size Standard_F1s \--generate-ssh-keys

Quite the call but let’s review the list below for each option specified:

  • --resource-group Your chosen unique resource group name.
  • --name Your chosen unique virtual machine name.
  • --public-ip-address-dns-name Your chosen unique website name that will be prepended to the ‘’ sub-domain.
  • --image The virtual mahcine image we chose.
  • --size The size of our virtual machine.
  • --generate-ssh-keys Generate SSH public and private key files if missing from your local environment (~/.ssh/).

Take note that not all location and size combinations work. Azure will respond with a code of ‘SkuNotAvailable’ if so. You will have to change the size or the location of the resource group to proceed.

Your virtual machine should now be running. You can ssh into it:


The current working directory with be /home/$USER, ‘$USER’ being you local username.


In this article we have created a resource group and virtual machine in Azure’s cloud. In the following article, Part 2, we explore creating the rest of the stack using Nginx, MySQL, and PHP with a Laravel sample project using an installation script.


Daydreaming night owl, giver of unsolicited advice, software engineer by passion, always learning and ever living...

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store