You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Deploy your first PHP Hello World to Azure App Service in minutes. You deploy using Git, which is one of many ways to deploy to App Service.
[Azure App Service](overview.md) provides a highly scalable, self-patching web hosting service. This quickstart shows how to deploy a PHP app to Azure App Service on Linux.
21
+
[Azure App Service](overview.md) provides a highly scalable, self-patching service for web hosting. This quickstart shows how to deploy a PHP app to Azure App Service on Linux.
22
22
23
-

23
+
:::image type="content" source="media/quickstart-php/hello-world-in-browser.png" alt-text="Screenshot of the sample app running in Azure.":::
24
24
25
-
You can follow the steps here using a Mac, Windows, or Linux machine. Once the prerequisites are installed, it takes about five minutes to complete the steps.
25
+
You can follow the steps here using a Mac, Windows, or Linux machine. Once the prerequisites are installed, it takes about ten minutes to complete the steps.
26
26
27
-
To complete this quickstart, you need:
27
+
## Prerequisites
28
28
29
29
* An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/).
30
30
*[Git](https://git-scm.com/)
31
-
*[PHP](https://php.net/manual/install.php)
31
+
*[PHP](https://php.net/downloads.php)
32
32
*[Azure CLI](/cli/azure/install-azure-cli) to run commands in any shell to create and configure Azure resources.
33
33
34
-
## 1 - Get the sample repository
34
+
## Download the sample repository
35
35
36
36
### [Azure CLI](#tab/cli)
37
37
38
-
You can create the web app using the [Azure CLI](/cli/azure/get-started-with-azure-cli) in Cloud Shell, and you use Git to deploy sample PHP code to the web app.
38
+
You can create the web app by using the [Azure CLI](/cli/azure/get-started-with-azure-cli), and you use Git to deploy sample PHP code to the web app.
39
39
40
40
1. In a terminal window, run the following commands to clone the sample application to your local machine and navigate to the project root.
41
41
@@ -49,11 +49,11 @@ You can create the web app using the [Azure CLI](/cli/azure/get-started-with-azu
49
49
```bash
50
50
php -S localhost:8080
51
51
```
52
-
52
+
53
53
1. Browse to the sample application at `http://localhost:8080`in a web browser.
54
-
55
-

56
-
54
+
55
+
:::image type="content" source="media/quickstart-php/localhost-hello-world-in-browser.png" alt-text="Screenshot of the sample app running locally.":::
56
+
57
57
1. In your terminal window, press **Ctrl+C** to exit the web server.
58
58
59
59
### [Portal](#tab/portal)
@@ -62,24 +62,24 @@ You can create the web app using the [Azure CLI](/cli/azure/get-started-with-azu
62
62
63
63
1. In the upper right corner, select**Fork**.
64
64
65
-

65
+
:::image type="content" source="media/quickstart-php/fork-php-docs-hello-world-repo.png" alt-text="Screenshot of the Azure Samples repo in GitHub, with the Fork option highlighted.":::
66
66
67
67
1. On the **Create a new fork** screen, confirm the **Owner** and **Repository name** fields. Select **Create fork**.
68
68
69
-

69
+
:::image type="content" source="media/quickstart-php/fork-details-php-docs-hello-world-repo.png" alt-text="Screenshot of the Create a new fork page in GitHub for creating a new fork of AzureSamples.":::
70
70
71
71
>[!NOTE]
72
-
> This should take you to the new fork. Your fork URL will look something like this: `https://github.com/YOUR_GITHUB_ACCOUNT_NAME/php-docs-hello-world`
72
+
> This should take you to the new fork. Your fork URL looks something like this: `https://github.com/YOUR_GITHUB_ACCOUNT_NAME/php-docs-hello-world`
73
73
74
74
---
75
75
76
-
## 2 - Deploy your application code to Azure
76
+
## Deploy your application code to Azure
77
77
78
78
### [Azure CLI](#tab/cli)
79
79
80
80
Azure CLI has a command [`az webapp up`](/cli/azure/webapp#az-webapp-up) that creates the necessary resources and deploys your application in a single step.
81
81
82
-
In the terminal, deploy the code in your local folder using the [`az webapp up`](/cli/azure/webapp#az-webapp-up) command:
82
+
In the terminal, deploy the code in your local folder using the `az webapp up` command:
83
83
84
84
```azurecli
85
85
az webapp up --runtime "PHP:8.2" --os-type=linux
@@ -89,62 +89,62 @@ az webapp up --runtime "PHP:8.2" --os-type=linux
89
89
- The `--runtime "PHP:8.2"` argument creates the web app with PHP version 8.2.
90
90
- The `--os-type=linux` argument creates the web app on App Service on Linux.
91
91
- You can optionally specify a name with the argument `--name <app-name>`. If you don't provide one, then a name is automatically generated.
92
-
- You can optionally include the argument `--location <location-name>` where `<location_name>` is an available Azure region. You can retrieve a list of allowable regions for your Azure account by running the [`az account list-locations`](/cli/azure/appservice#az_appservice_list_locations) command.
93
-
- If you see the error, "Could not auto-detect the runtime stack of your app," make sure you're running the command in the code directory (See [Troubleshooting auto-detect issues with az webapp up](https://github.com/Azure/app-service-linux-docs/blob/master/AzWebAppUP/runtime_detection.md)).
92
+
- You can optionally include the argument `--location <location-name>` where `<location_name>` is an available Azure region. You can retrieve a list of allowable regions for your Azure account by running the [`az account list-locations`](/cli/azure/appservice#az-appservice-list-locations) command.
93
+
- If you see the error**Could not auto-detect the runtime stack of your app**, make sure you're running the command in the code directory. To learn more, see [Troubleshooting auto-detect issues with az webapp up](https://github.com/Azure/app-service-linux-docs/blob/master/AzWebAppUP/runtime_detection.md).
94
94
95
-
The command can take a few minutes to complete. While it's running, it provides messages about creating the resource group, the App Service plan, and the app resource, configuring logging, and doing ZIP deployment. It thengives the message, "You can launch the app at http://<app-name>.azurewebsites.net", which is the app's URL on Azure.
95
+
The command can take a few minutes to complete. While it's running, it provides messages about creating the resource group, the App Service plan, and the app resource, configuring logging, and doing ZIP deployment. It thenprovides the app's URL on Azure.
Configuring default logging for the app, if not already enabled
104
-
Creating zip with contents of dir /home/msangapu/myPhpApp ...
104
+
Creating zip with contents of <directory-location> ...
105
105
Getting scm site credentials for zip deployment
106
106
Starting zip deployment. This operation can take a while to complete ...
107
107
Deployment endpoint responded with status code 202
108
-
You can launch the app at http://<app-name>.azurewebsites.net
108
+
You can launch the app at http://<app-name>.azurewebsites.net
109
109
{
110
-
"URL": "http://<app-name>.azurewebsites.net",
111
-
"appserviceplan": "<app-service-plan-name>",
110
+
"URL": "http://<app-name>.azurewebsites.net",
111
+
"appserviceplan": "<app-service-plan-name>",
112
112
"location": "centralus",
113
-
"name": "<app-name>",
113
+
"name": "<app-name>",
114
114
"os": "linux",
115
-
"resourcegroup": "<group-name>",
115
+
"resourcegroup": "<group-name>",
116
116
"runtime_version": "php|8.2",
117
117
"runtime_version_detected": "0.0",
118
118
"sku": "FREE",
119
-
"src_path": "//home//msangapu//myPhpApp"
119
+
"src_path": "<directory-path>"
120
120
}
121
-
</pre>
121
+
```
122
122
123
123
[!include [az webapp up command note](../../includes/app-service-web-az-webapp-up-note.md)]
124
124
125
-
Browse to the deployed application in your web browser at the URL `http://<app-name>.azurewebsites.net`.
125
+
Browse to the deployed application in your web browser at the URL that's provided in the terminal.
126
126
127
127
### [Portal](#tab/portal)
128
128
129
-
1. Sign into the Azure portal.
130
-
129
+
1. Sign in to [the Azure portal](https://portal.azure.com).
130
+
131
131
1. At the top of the portal, type **app services** in the search box. Under **Services**, select **App Services**.
132
132
133
-

133
+
:::image type="content" source="media/quickstart-php/azure-portal-search-for-app-services.png" alt-text="Screenshot of the Azure portal with app services typed in the search text box.":::
134
134
135
-
1. In the **App Services** page, select**+ Create**.
135
+
1. In the **App Services** page, select **+ Create** and choose **Web App**.
136
136
137
137
1. In the **Basics** tab:
138
138
139
139
- Under **Resource group**, select **Create new**. Type *myResourceGroup* for the name.
140
140
- Under **Name**, type a globally unique name for your web app.
141
-
- Under **Publish**, select*Code*.
142
-
- Under **Runtime stack**select*PHP 8.2*.
143
-
- Under **Operating System**, select*Linux*.
141
+
- Under **Publish**, select **Code**.
142
+
- Under **Runtime stack** select **PHP 8.2**.
143
+
- Under **Operating System**, select **Linux**.
144
144
- Under **Region**, select an Azure region close to you.
145
145
- Under **App Service Plan**, create an app service plan named *myAppServicePlan*.
146
146
- Under **Pricing plan**, select **Free F1**.
147
-
147
+
148
148
:::image type="content" source="./media/quickstart-php/app-service-details-php.png" lightbox="./media/quickstart-php/app-service-details-php.png" alt-text="Screenshot of new App Service app configuration for PHP in the Azure portal.":::
149
149
150
150
1. Select the **Deployment** tab at the top of the page.
@@ -155,10 +155,10 @@ Browse to the deployed application in your web browser at the URL `http://<app-n
155
155
156
156
- For **Organization** select the organization where you forked the demo project.
157
157
- For **Repository** select the *php-docs-hello-world* project.
158
-
- For **Branch**select*master*.
158
+
- For **Branch** select *main*.
159
159
160
160
:::image type="content" source="media/quickstart-php/app-service-deploy-php.png" lightbox="media/quickstart-php/app-service-deploy-php.png" border="true" alt-text="Screenshot of the deployment options for a PHP app.":::
161
-
161
+
162
162
> [!NOTE]
163
163
> By default, the creation wizard [disables basic authentication](configure-basic-auth-disable.md) and GitHub Actions deployment is created [using a user-assigned identity](deploy-continuous-deployment.md#what-does-the-user-assigned-identity-option-do-for-github-actions). If you get a permissions error during resource creation, your Azure account might not have [enough permissions](deploy-continuous-deployment.md#why-do-i-see-the-error-you-do-not-have-sufficient-permissions-on-this-app-to-assign-role-based-access-to-a-managed-identity-and-configure-federated-credentials). You can [configure GitHub Actions deployment later](deploy-continuous-deployment.md) with an identity generated for you by an Azure administrator, or you can also enable basic authentication instead.
164
164
@@ -168,21 +168,21 @@ Browse to the deployed application in your web browser at the URL `http://<app-n
168
168
169
169
1. After deployment is completed, select **Go to resource**.
170
170
171
-
1. Browse to the deployed application in your web browser at the URL `http://<app-name>.azurewebsites.net`.
171
+
1. Browse to the deployed application in your web browser at the URL provided.
172
172
173
173
---
174
174
175
175
The PHP sample code is running in an Azure App Service.
176
176
177
-

177
+
:::image type="content" source="media/quickstart-php/php-8-hello-world-in-browser.png" alt-text="Screenshot of the sample app running in Azure, showing Hello World.":::
178
178
179
179
**Congratulations!** You deployed your first PHP app to App Service using the Azure portal.
180
180
181
-
## 3 - Update and redeploy the app
181
+
## Update and redeploy the app
182
182
183
183
### [Azure CLI](#tab/cli)
184
184
185
-
1. Using a local text editor, open the `index.php` file within the PHP app, and make a small change to the text within the string next to `echo`:
185
+
1. Locate the directory *php-docs-hello-world* and open the *index.php* file using a local text editor. Make a small change to the text within the string next to `echo`:
186
186
187
187
```php
188
188
echo "Hello Azure!";
@@ -196,20 +196,20 @@ The PHP sample code is running in an Azure App Service.
196
196
197
197
1. Once deployment is completed, return to the browser window that opened during the **Browse to the app** step, and refresh the page.
198
198
199
-

199
+
:::image type="content" source="media/quickstart-php/hello-azure-in-browser.png" alt-text="Screenshot of the updated sample app running in Azure.":::
200
200
201
201
### [Portal](#tab/portal)
202
202
203
203
1. Browse to your GitHub fork of php-docs-hello-world.
204
204
205
205
1. On your repo page, press `.` to start Visual Studio Code within your browser.
206
206
207
-

207
+
:::image type="content" source="media/quickstart-php/forked-github-repo-press-period.png" alt-text="Screenshot of the forked php-docs-hello-world repo in GitHub with instructions to press the period key on this screen.":::
208
208
209
209
> [!NOTE]
210
-
> The URL will change from GitHub.com to GitHub.dev. This feature only works with repos that have files. This does not work on empty repos.
210
+
> The URL changes from GitHub.com to GitHub.dev. This feature only works with repos that have files. This doesn't work on empty repos.
211
211
212
-
1. Edit **index.php** so that it shows "Hello Azure!" instead of "Hello World!"
212
+
1. Edit *index.php* so that it shows *Hello Azure!* instead of *Hello World!*
213
213
214
214
```php
215
215
<?php
@@ -219,37 +219,37 @@ The PHP sample code is running in an Azure App Service.
219
219
220
220
1. From the **Source Control** menu, selectthe**Stage Changes** button to stage the change.
221
221
222
-

222
+
:::image type="content" source="media/quickstart-php/visual-studio-code-in-browser-stage-changes.png" alt-text="Screenshot of Visual Studio Code in the browser, highlighting the Source Control navigation in the sidebar, then highlighting the Stage Changes button in the Source Control panel.":::
223
223
224
-
1. Enter a commit message such as `Hello Azure`. Then, select**Commit and Push**.
225
-
226
-

224
+
1. Enter a commit message such as *Hello Azure*. Then, select**Commit and Push**.
227
225
228
-
1. Once deployment is completed, return to the browser window that opened during the **Browse to the app** step, and refresh the page.
226
+
:::image type="content" source="media/quickstart-php/visual-studio-code-in-browser-commit-push.png" alt-text="Screenshot of Visual Studio Code in the browser, Source Control panel with a commit message of Hello Azure.":::
229
227
230
-

228
+
1. After deployment is complete, return to the browser window that opened during the **Browse to the app** step, and refresh the page.
229
+
230
+
:::image type="content" source="media/quickstart-php/php-8-hello-azure-in-browser.png" alt-text="Screenshot of the updated sample app running in Azure, showing Hello Azure.":::
231
231
232
232
---
233
233
234
-
## 4 - Manage your new Azure app
234
+
## Manage your new Azure app
235
235
236
236
1. Go to the Azure portal to manage the web app you created. Search for and select**App Services**.
237
237
238
-

238
+
:::image type="content" source="media/quickstart-php/azure-portal-search-for-app-services.png" alt-text="Screenshot of the Azure portal with app services typed in the search text box.":::
239
239
240
-
1. Select the name of your Azure app.
240
+
1. Select your Azure app to open it.
241
241
242
-

242
+
:::image type="content" source="media/quickstart-php/app-service-list.png" alt-text="Screenshot of the App Services list in Azure. The name of the demo app service is highlighted.":::
243
243
244
244
Your web app's **Overview** page should be displayed. Here, you can perform basic management tasks like **Browse**, **Stop**, **Restart**, and **Delete**.
245
245
246
-

246
+
:::image type="content" source="media/quickstart-php/app-service-detail.png" alt-text="Screenshot of the App Service overview page in Azure portal. In the action bar, the Browse, Stop, Swap, Restart, and Delete button group is highlighted.":::
247
247
248
248
The web app menu provides different options for configuring your app.
249
249
250
-
## 5 - Clean up resources
250
+
## Clean up resources
251
251
252
-
When you're finished with the sample app, you can remove all of the resources forthe app from Azure. It helps you avoid extra charges and keeps your Azure subscription uncluttered. Removing the resource group also removes all resourcesin the resource group and is the fastest way to remove all Azure resources for your app.
252
+
When you're finished with the sample app, you can remove all of the resources forthe app from Azure so you can avoid extra charges and keep your Azure subscription uncluttered. Removing the resource group also removes all resourcesin the resource group and is the fastest way to remove all Azure resources for your app.
253
253
254
254
### [Azure CLI](#tab/cli)
255
255
@@ -271,13 +271,8 @@ This command takes a minute to run.
271
271
272
272
::: zone-end
273
273
274
-
## Next steps
275
-
276
-
> [!div class="nextstepaction"]
277
-
> [PHP with MySQL](tutorial-php-mysql-app.md)
278
-
279
-
> [!div class="nextstepaction"]
280
-
> [Configure PHP app](configure-language-php.md)
274
+
## Related content
281
275
282
-
> [!div class="nextstepaction"]
283
-
> [Secure with custom domain and certificate](tutorial-secure-domain-certificate.md)
276
+
* [Deploy a PHP, MySQL, and Redis app to Azure App Service](tutorial-php-mysql-app.md)
277
+
* [Configure a PHP app for Azure App Service](configure-language-php.md)
278
+
* [Secure your app with a custom domain and a managed certificate](tutorial-secure-domain-certificate.md)
0 commit comments