Skip to content

Commit f087ad7

Browse files
Merge pull request #298643 from cdpark/refresh-appservice-batch3
User Story 419632: Q&M: Freshness - Azure App Service - Apr - batch 3
2 parents 65f4104 + a9c4cec commit f087ad7

File tree

3 files changed

+107
-106
lines changed

3 files changed

+107
-106
lines changed

articles/app-service/configure-language-php.md

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,38 @@ title: Configure a PHP App
33
description: Learn how to configure a PHP app in a prebuilt PHP container in Azure App Service. This article shows the most common configuration tasks.
44
ms.devlang: php
55
ms.topic: how-to
6-
ms.date: 04/01/2025
6+
ms.date: 04/22/2025
77
ms.custom: devx-track-azurecli, linux-related-content
88
zone_pivot_groups: app-service-platform-windows-linux
99
ms.author: msangapu
1010
author: msangapu-msft
1111
#customer intent: As an app developer who uses PHP, I want to understand how to configure my PHP web apps in Azure App Service.
1212
---
1313

14-
# Configure a PHP app for Azure App Service
14+
# Configure a PHP app in Azure App Service
1515

1616
::: zone pivot="platform-windows"
1717

1818
[!INCLUDE [php-eol-notice](./includes/php-windows-eol-notice.md)]
1919

20-
This guide shows you how to configure your PHP web apps, mobile back ends, and API apps in Azure App Service.
20+
This guide shows you how to configure your PHP web apps, mobile back ends, and API apps in Azure App Service. The most common configuration tasks are covered.
2121

22-
This guide provides key concepts and instructions for PHP developers who deploy apps to App Service. If you're new to App Service, you should first follow the [Create a PHP web app in Azure App Service](quickstart-php.md) quickstart and the [Deploy a PHP, MySQL, and Redis app to Azure App Service](tutorial-php-mysql-app.md) tutorial.
22+
If you're new to App Service, you should first follow the [Create a PHP web app in Azure App Service](quickstart-php.md) quickstart and the [Deploy a PHP, MySQL, and Redis app to Azure App Service](tutorial-php-mysql-app.md) tutorial.
2323

2424
## Show the PHP version
2525

26-
To show the current PHP version, run the following command in [Azure Cloud Shell](https://shell.azure.com):
26+
To show the current PHP version, run the following command. You can use the [Azure Cloud Shell](https://shell.azure.com):
2727

2828
```azurecli-interactive
2929
az webapp config show --resource-group <resource-group-name> --name <app-name> --query phpVersion
3030
```
3131

32+
Replace `<resource-group-name>` and `<app-name>` with names that are appropriate for your web app.
33+
3234
> [!NOTE]
3335
> To address a development slot, include the parameter `--slot` followed by the name of the slot.
3436
35-
To show all supported PHP versions, run the following command in Cloud Shell:
37+
To show all supported PHP versions, run the following command:
3638

3739
```azurecli-interactive
3840
az webapp list-runtimes --os windows | grep PHP
@@ -42,22 +44,24 @@ az webapp list-runtimes --os windows | grep PHP
4244

4345
::: zone pivot="platform-linux"
4446

45-
This guide shows you how to configure your PHP web apps, mobile back ends, and API apps in Azure App Service.
47+
This guide shows you how to configure your PHP web apps, mobile back ends, and API apps in Azure App Service. The most common configuration tasks are covered.
4648

47-
This guide provides key concepts and instructions for PHP developers who deploy apps to App Service. If you're new to App Service, you should first follow the [Create a PHP web app in Azure App Service](quickstart-php.md) quickstart and the [Deploy a PHP, MySQL, and Redis app to Azure App Service](tutorial-php-mysql-app.md) tutorial.
49+
If you're new to App Service, you should first follow the [Create a PHP web app in Azure App Service](quickstart-php.md) quickstart and the [Deploy a PHP, MySQL, and Redis app to Azure App Service](tutorial-php-mysql-app.md) tutorial.
4850

4951
## Show the PHP version
5052

51-
To show the current PHP version, run the following command in [Azure Cloud Shell](https://shell.azure.com):
53+
To show the current PHP version, run the following command. You can use the [Azure Cloud Shell](https://shell.azure.com).
5254

5355
```azurecli-interactive
5456
az webapp config show --resource-group <resource-group-name> --name <app-name> --query linuxFxVersion
5557
```
5658

59+
Replace `<resource-group-name>` and `<app-name>` with names that are appropriate for your web app.
60+
5761
> [!NOTE]
5862
> To address a development slot, include the parameter `--slot` followed by the name of the slot.
5963
60-
To show all supported PHP versions, run the following command in Cloud Shell:
64+
To show all supported PHP versions, run the following command:
6165

6266
```azurecli-interactive
6367
az webapp list-runtimes --os linux | grep PHP
@@ -69,7 +73,7 @@ az webapp list-runtimes --os linux | grep PHP
6973

7074
::: zone pivot="platform-windows"
7175

72-
To set the PHP version to 8.1, run the following command in [Cloud Shell](https://shell.azure.com):
76+
To set the PHP version to 8.1, run the following command:
7377

7478
```azurecli-interactive
7579
az webapp config set --resource-group <resource-group-name> --name <app-name> --php-version 8.1
@@ -79,7 +83,7 @@ az webapp config set --resource-group <resource-group-name> --name <app-name> --
7983

8084
::: zone pivot="platform-linux"
8185

82-
To set the PHP version to 8.1, run the following command in [Cloud Shell](https://shell.azure.com):
86+
To set the PHP version to 8.1, run the following command:
8387

8488
```azurecli-interactive
8589
az webapp config set --resource-group <resource-group-name> --name <app-name> --linux-fx-version "PHP|8.1"
@@ -232,11 +236,11 @@ az webapp config appsettings set --name <app-name> --resource-group <resource-gr
232236

233237
For other environment variables to customize build automation, see [Oryx configuration](https://github.com/microsoft/Oryx/blob/master/doc/configuration.md).
234238

235-
For more information on how App Service runs and builds PHP apps in Linux, see the [Oryx documentation on how PHP apps are detected and built](https://github.com/microsoft/Oryx/blob/master/doc/runtimes/php.md).
239+
To learn how App Service runs and builds PHP apps in Linux, see the [Oryx documentation on how PHP apps are detected and built](https://github.com/microsoft/Oryx/blob/master/doc/runtimes/php.md).
236240

237241
## Customize startup
238242

239-
You can run a custom command at the container startup time. Run the following command in [Cloud Shell](https://shell.azure.com):
243+
You can run a custom command at the container startup time. Run the following command:
240244

241245
```azurecli-interactive
242246
az webapp config set --resource-group <resource-group-name> --name <app-name> --startup-file "<custom-command>"
@@ -272,7 +276,7 @@ By default, Azure App Service points the root virtual application path (`/`) to
272276

273277
The web framework of your choice might use a subdirectory as the site root. For example, [Laravel](https://laravel.com/) uses the `public/` subdirectory as the site root.
274278

275-
The default PHP image for App Service uses NGINX, and you change the site root by [configuring the NGINX server with the `root` directive](https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/). [This example configuration file](https://github.com/Azure-Samples/laravel-tasks/blob/main/default) contains the following snippet that changes the `root` directive:
279+
The default PHP image for App Service uses NGINX, and you change the site root by [configuring the NGINX server with the `root` directive](https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/). This [example configuration file](https://github.com/Azure-Samples/laravel-tasks/blob/main/default) contains the following snippet that changes the `root` directive:
276280

277281
```output
278282
server {
@@ -343,15 +347,15 @@ As an alternative to using a `.user.ini` file, you can use [`ini_set()`](https:/
343347

344348
::: zone pivot="platform-linux"
345349

346-
To customize `PHP_INI_USER`, `PHP_INI_PERDIR`, and `PHP_INI_ALL` directives for Linux web apps, such as `upload_max_filesize` and `expose_php`, use a custom .ini file. You can create it in an [SSH session](configure-linux-open-ssh-session.md). First, set up the directory:
350+
To customize `PHP_INI_USER`, `PHP_INI_PERDIR`, and `PHP_INI_ALL` directives for Linux web apps, such as `upload_max_filesize` and `expose_php`, use a custom *.ini* file. You can create it in an [SSH session](configure-linux-open-ssh-session.md). First, set up the directory:
347351

348-
1. Go to your Kudu site, by default: `https://<app-name>-<random-hash>.scm.<region>.azurewebsites.net/`. To get the random hash and region values, in your app **Overview**, copy **Default domain**.
352+
1. Go to your Kudu site. To get the random hash and region values, in your app **Overview**, copy **Default domain**.
349353
1. On the top menu, select **Debug console**, then **Bash** or **SSH**.
350354
1. In Bash or SSH, go to your `/home/site/wwwroot` directory.
351355
1. Create a directory called `ini` (for example, `mkdir ini`).
352356
1. Change the current working directory to the `ini` folder that you created.
353357

354-
Next, create an .ini file where you add your settings. This example uses `extensions.ini`. There are no file editors such as Vi, Vim, or Nano, so use Echo to add the settings to the file. Change the `upload_max_filesize` value from `2M` to `50M`. Use the following command to add the setting and create an `extensions.ini` file if one doesn't already exist:
358+
Next, create an *.ini* file where you add your settings. This example uses `extensions.ini`. There are no file editors such as Vi, Vim, or Nano, so use `Echo` to add the settings to the file. Change the `upload_max_filesize` value from `2M` to `50M`. Use the following command to add the setting and create an `extensions.ini` file if one doesn't already exist:
355359

356360
```bash
357361
/home/site/wwwroot/ini>echo "upload_max_filesize=50M" >> extensions.ini
@@ -366,7 +370,7 @@ In the Azure portal, add an application setting to scan the `ini` directory that
366370

367371
1. Go to the [Azure portal](https://portal.azure.com) and select your App Service Linux PHP application.
368372
1. Go to **Settings** > **Environment variables**.
369-
1. Select **Add**.
373+
1. Select **+ Add**.
370374
1. For **Name** enter *PHP_INI_SCAN_DIR* and for **Value**, enter `:/home/site/wwwroot/ini`.
371375
1. Select **Apply**, then **Apply** again. Confirm your changes.
372376

@@ -381,15 +385,15 @@ In the Azure portal, add an application setting to scan the `ini` directory that
381385

382386
To customize `PHP_INI_SYSTEM` directives, use the `PHP_INI_SCAN_DIR` app setting.
383387

384-
First, run the following command in [Cloud Shell](https://shell.azure.com) to add an app setting called `PHP_INI_SCAN_DIR`:
388+
First, run the following command to add an app setting called `PHP_INI_SCAN_DIR`:
385389

386390
```azurecli-interactive
387391
az webapp config appsettings set --name <app-name> --resource-group <resource-group-name> --settings PHP_INI_SCAN_DIR="d:\home\site\ini"
388392
```
389393

390-
Go to the Kudu console (`https://<app-name>-<random-hash>.scm.<region>.azurewebsites.net/DebugConsole`), and then go to `d:\home\site`.
394+
In the Azure portal, select your app. Under **Development Tools** in the sidebar menu, select **Advanced Tools**, and then go to `d:\home\site` using SSH.
391395

392-
Create a directory in `d:\home\site` called `ini`. Then, create an .ini file in the `d:\home\site\ini` directory, for example, `settings.ini`, with the directives that you want to customize. Use the same syntax that you would use in a `php.ini` file.
396+
Create a directory in `d:\home\site` called `ini`. Then, create an *.ini* file in the `d:\home\site\ini` directory, for example, `settings.ini`, with the directives that you want to customize. Use the same syntax that you would use in a `php.ini` file.
393397

394398
For example, to change the value of [`expose_php`](https://php.net/manual/ini.core.php#ini.expose-php), run the following commands:
395399

@@ -405,19 +409,19 @@ For the changes to take effect, restart the app.
405409

406410
::: zone pivot="platform-linux"
407411

408-
To customize `PHP_INI_SYSTEM` directives, you can't use the `.htaccess` approach. App Service provides a separate mechanism that uses the `PHP_INI_SCAN_DIR` app setting.
412+
To customize `PHP_INI_SYSTEM` directives, you can't use the *.htaccess* approach. App Service provides a separate mechanism that uses the `PHP_INI_SCAN_DIR` app setting.
409413

410-
First, run the following command in [Cloud Shell](https://shell.azure.com) to add an app setting called `PHP_INI_SCAN_DIR`:
414+
First, run the following command to add an app setting called `PHP_INI_SCAN_DIR`:
411415

412416
```azurecli-interactive
413417
az webapp config appsettings set --name <app-name> --resource-group <resource-group-name> --settings PHP_INI_SCAN_DIR="/usr/local/etc/php/conf.d:/home/site/ini"
414418
```
415419

416-
The value `/usr/local/etc/php/conf.d` is the default directory where `php.ini` exists. The value `/home/site/ini` is the custom directory in which you add a custom .ini file. You separate the values with a colon (`:`).
420+
The value `/usr/local/etc/php/conf.d` is the default directory where `php.ini` exists. The value `/home/site/ini` is the custom directory in which you add a custom *.ini* file. You separate the values with a colon (`:`).
417421

418-
Go to the web SSH session with your Linux container (`https://<app-name>-<random-hash>.scm.<region>.azurewebsites.net/webssh/host`).
422+
Go to the web SSH session with your Linux container.
419423

420-
Create a directory in `/home/site` called `ini`. Then, create an .ini file in the `/home/site/ini` directory, for example, `settings.ini`, with the directives that you want to customize. Use the same syntax that you would use in a `php.ini` file.
424+
Create a directory in `/home/site` called `ini`. Then, create an *.ini* file in the `/home/site/ini` directory, for example, `settings.ini`, with the directives that you want to customize. Use the same syntax that you would use in a `php.ini` file.
421425

422426
> [!TIP]
423427
> The built-in Linux containers in App Service use `/home` as persisted shared storage.
@@ -445,7 +449,7 @@ The built-in PHP installations contain the most commonly used extensions. You ca
445449
446450
To enable other extensions, use the following steps:
447451

448-
1. Add a `bin` directory to the root directory of your app, and put the `.dll` extension files in it, for example, `mongodb.dll`. Make sure that the extensions are compatible with the PHP version in Azure, and that they're VC9 and non-thread-safe (NTS) compatible.
452+
1. Add a `bin` directory to the root directory of your app, and put the *.dll* extension files in it, for example, `mongodb.dll`. Make sure that the extensions are compatible with the PHP version in Azure, and that they're VC9 and non-thread-safe (NTS) compatible.
449453

450454
1. Deploy your changes.
451455

@@ -469,7 +473,7 @@ The built-in PHP installations contain the most commonly used extensions. You ca
469473
470474
To enable other extensions, use the following steps:
471475

472-
1. Add a `bin` directory to the root directory of your app, and put the `.so` extension files in it (for example, `mongodb.so`). Make sure that the extensions are compatible with the PHP version in Azure, and that they're VC9 and non-thread-safe (NTS) compatible.
476+
1. Add a `bin` directory to the root directory of your app, and put the *.so* extension files in it (for example, `mongodb.so`). Make sure that the extensions are compatible with the PHP version in Azure, and that they're VC9 and non-thread-safe (NTS) compatible.
473477

474478
1. Deploy your changes.
475479

@@ -504,7 +508,7 @@ Use the standard [`error_log()`](https://php.net/manual/function.error-log.php)
504508

505509
When a working PHP app behaves differently in App Service or has errors, try the following solutions:
506510

507-
- [Access the log stream](#access-diagnostic-logs).
511+
- Access the [diagnostic log stream](#access-diagnostic-logs).
508512
- Test the app locally in production mode. App Service runs your app in production mode, so you need to make sure that your project works as expected in production mode locally. For example:
509513
- Depending on your `composer.json` file, different packages might be installed for production mode (`require` versus `require-dev`).
510514
- Certain web frameworks might deploy static files differently in production mode.

0 commit comments

Comments
 (0)