Azure hosting LEMP with PHP 7.1 and Laravel 5.4 — Part 2
This article discusses getting the rest of the LEMP stack up and running from the command line in the Azure virtual machine host we created in Part 1.
The following commands are being run from a Mac OS X machine and should be translatable to a Linux or Windows environment. The installation scripts that follow have been tested on Ubuntu 16.04 LTS.
CONVENTIONS
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.
LEMP
We have our ‘L’, now let’s create the rest of the acronym.
(E) Nginx, (M)ySQL, (P)HP with Laravel
Before we create the rest of the stack, the Azure virtual machine host needs to be accessible to the outside world.
HTTP
az vm open-port --port 80 --priority 900 --resource-group {UNIQUE_RESOURCE-GROUP_NAME} --name {UNIQUE_VIRTUAL-MACHINE_NAME}
Install Scripts
The following are three scripts that will be copied over to local, then host, and finally executed on the host:
There is a lot going on in those scripts and ‘install.sh’ in particular has been commented to express what is happening.
Please feel free to use the comment section to ask for further explainantion on parts of the script.
Let’s move on to execute the following:
Copy to Local
curl --silent --location --output install.sh https://git.io/v7NVt --output ni-msi.sh https://git.io/v7Nwt --output mysql_credentials.cnf https://git.io/v7NwK && chmod +x install.sh ni-msi.sh
Copy to Host
scp -pq install.sh ni-msi.sh mysql_credentials.cnf $USER@{UNIQUE_VIRTUAL-MACHINE_NAME}.eastus.cloudapp.azure.com:~/
The options for secure copy (scp
) are preserve file (-p
) and quiet (-q
).
Run on Host
ssh $USER@{UNIQUE_VIRTUAL-MACHINE_NAME}.eastus.cloudapp.azure.com "~/./install.sh"
The last command above will start the install process on the host and you should see output on your terminal as the lines in the script are executed. When the final command is executed, the example Laravel application should be viewable through a web browser:
http://{UNIQUE_VIRTUAL-MACHINE_NAME}.eastus.cloudapp.azure.com
At this point you can create users and log into the example application.
Conclusion
In this article we have completed installation of a Nginx Laravel application using MySQL to store created users in a Azure virtual machine host. The final part (Part 3) will add SSL to Nginx so that users can access the example application through HTTPS.