DEV Community

Arne
Arne

Posted on

How to deploy a Laravel 5.4 (PHP) Application to Microsoft Azure WebApp service

You’ve certainly noticed it, there was just a little silence.
This is mainly due to the change of my employer, after 20 years in an energy company, it has left me in a smaller german “Startup (ZENNER IoT Solutions), which is costs me some time at the moment (which is completely OK for me!) – what we do? Building a great IoT Platform!

There we are happy to participate in the Microsoft BizSpark program,
which means some resources, such as testing Microsoft’s Azure Cloud.
Now my task was to bring a PHP application based on the Laravel 5.4 fFramework to a web app from Microsoft. Microsoft WebApps are their PaaS offer when it comes to hosting .. Surprise: Web applications.

The base of the WebApps is an iiS server, which makes the whole story a bit more complex than deploying to a 08/15 Apache with PHP .. the iiS is more suitable for Microsoft’s languages like ASP.NET etc. Well, however, nothing is impossible. Here is a short story on how to deploy a Laravel App to Microsoft Azure WebApp Service (Spoiler: It runs very well, if it runs!).

Let’s assume that your application is finished, and you have already set up
an Azure WebApp (which is trivial). Now we have to do some preparations.

PHP Setting for the Azure WebApp

Let ‘s start with a new PHP version for our WebApp. Fortunately, Microsoft supports PHP 7.1, which we also now select in the Applications – Settings.

Azure and Laravel

Azure and Laravel

Configure the Azure WebApp for Laravel

Further on the same page, here a few variables we have to set, so that Azure plays well with Laravel.

-SCM_REPOSITORY_PATH to: ..\repository
-SCM_TARGET_PATH to: ..

Azure and Laravel

Now it is time to change the entry point to our website, the default for Azure is “/site/index.html”, but Laravel want’s : “site/public”. But hey we can also do this on the same page.

Azure and Laravel

The matching counterpart to the Apache .htaccess, is the iiS “web.config file, fortunately Laravel ships with a default one, we can use for our application. So no work for us.

Composer extension for WebApp

The settings now fit, what makes life even easier for us is an extension that you can simply activate, so you make sure that “composer is executed during the deployment and you do not have to do this manually.

Azure and Laravel

Azure and Laravel

Azure and Laravel

Deployment “pipeline for our Azure WebApp

The last step: Somehow we must get our application to Azure. Personally, I prefer the deployment via GIT, we clone some kind of a local repository and copy our code into it. After a short “git push we are online, Hooray.

Azure and Laravel

Azure and Laravel

Top comments (2)

Collapse
 
olivedev profile image
olivedev

Haven't used Azure, but I have great experience with DO and Linode. They are both great for hosting your small-mid level laravel app. I used Cloudways Laravel hosting platform host my app on the provider and use Envoyer to deploy the app quickly. This makes the process much quicker.

Collapse
 
allan2012 profile image
Allan Kibet

Great tutorial.