Let me start with a “Hello World” example in PHP and put it on Microsoft Azure.
Hello World in PHP
I start with a file called “index.php” as it will be our entry point for web requests. In that file I write the following code:
<?php
$helloWorld = "Hello World from Azure!";
?>
<html>
<head>
<title><?php echo $helloWorld ?></title>
</head>
<body>
<h1><?php echo $helloWorld ?></h1>
</body>
</html>
Because I saved this code in a file I can use the build-in web server from PHP to verify this code does what I expect it to do.
php -S localhost:8080 index.php
When I point my browser to http://localhost:8080/ I see the Hello World example.
![](https://www.azurephp.dev/wp-content/uploads/2021/04/Hello-World-on-localhost-1024x543.png)
This quick check confirms that my page works. I now want to publish this page on Azure.
Sign up for an Azure account
If you don’t have an Azure account yet, create one. Look at my post Create a free Azure account for details on what to expect and a step-by-step guide to create a free account.
Create an App Service in Azure
Azure App Services are fully managed platform by Microsoft for building, deploying and scaling your web applications. It’s a “Platform as a Service” or PaaS where you need to focus on your own code while Microsoft takes care of the platform and infrastructure underneath.
I assume that you already have an Azure account if you want to follow along.
Step 1: Create a resource group
The first step is to create a “Resource Group” which is a logical grouping of applications and services, similar as a project root folder. Here we will create all components that are required for running our example.
![](https://www.azurephp.dev/wp-content/uploads/2021/04/Create-a-resource-group-1024x566.png)
In this example I create a resource group “AzurePHPRG” and this will be the main resource group throughout most of the examples on this blog.
Step 2: Create an App Service
Within our resource group we’re going to create a new App Service that will host our Hello World example.
![](https://www.azurephp.dev/wp-content/uploads/2021/04/Create-a-web-app-1024x566.png)
Once the web app is created and running, it doesn’t have our code yet. There are many ways to get your code onto the app service which I will discuss in more detail in other blog articles. For this example I will use the build-in Kudu directory editor.
![](https://www.azurephp.dev/wp-content/uploads/2021/04/Use-the-Kudu-editor-for-quick-testing-1024x566.png)
After saving this code, I can point my browser to php-helloworld-from-azure.azurewebsites.net to see the result of my work.
![](https://www.azurephp.dev/wp-content/uploads/2021/04/Hello-World-on-Azure-1024x652.png)
This is just an introduction to running PHP applications on Azure. Next articles will cover how to connect with a Azure Databases for MySQL and how to secure your secrets with Azure Key Vault.
[…] this article I continue from where I ended in my “Hello World From Azure” article. Please read that first before continuing […]