Skip to content

Commit 3a60e36

Browse files
committed
Second article
1 parent 7b8edcb commit 3a60e36

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
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"
@@ -230,11 +234,11 @@ az webapp config appsettings set --name <app-name> --resource-group <resource-gr
230234

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

233-
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).
237+
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).
234238

235239
## Customize startup
236240

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

239243
```azurecli-interactive
240244
az webapp config set --resource-group <resource-group-name> --name <app-name> --startup-file "<custom-command>"
@@ -270,7 +274,7 @@ By default, Azure App Service points the root virtual application path (`/`) to
270274

271275
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.
272276

273-
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:
277+
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:
274278

275279
```output
276280
server {
@@ -341,15 +345,15 @@ As an alternative to using a `.user.ini` file, you can use [`ini_set()`](https:/
341345

342346
::: zone pivot="platform-linux"
343347

344-
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:
348+
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:
345349

346-
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**.
350+
1. Go to your Kudu site. To get the random hash and region values, in your app **Overview**, copy **Default domain**.
347351
1. On the top menu, select **Debug console**, then **Bash** or **SSH**.
348352
1. In Bash or SSH, go to your `/home/site/wwwroot` directory.
349353
1. Create a directory called `ini` (for example, `mkdir ini`).
350354
1. Change the current working directory to the `ini` folder that you created.
351355

352-
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:
356+
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:
353357

354358
```bash
355359
/home/site/wwwroot/ini>echo "upload_max_filesize=50M" >> extensions.ini
@@ -364,7 +368,7 @@ In the Azure portal, add an application setting to scan the `ini` directory that
364368

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

@@ -379,15 +383,15 @@ In the Azure portal, add an application setting to scan the `ini` directory that
379383

380384
To customize `PHP_INI_SYSTEM` directives, use the `PHP_INI_SCAN_DIR` app setting.
381385

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

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

388-
Go to the Kudu console (`https://<app-name>-<random-hash>.scm.<region>.azurewebsites.net/DebugConsole`), and then go to `d:\home\site`.
392+
Go to the Kudu console, and then go to `d:\home\site`.
389393

390-
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.
394+
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.
391395

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

@@ -403,19 +407,19 @@ For the changes to take effect, restart the app.
403407

404408
::: zone pivot="platform-linux"
405409

406-
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.
410+
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.
407411

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

410414
```azurecli-interactive
411415
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"
412416
```
413417

414-
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 (`:`).
418+
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 (`:`).
415419

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

418-
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.
422+
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.
419423

420424
> [!TIP]
421425
> The built-in Linux containers in App Service use `/home` as persisted shared storage.
@@ -443,7 +447,7 @@ The built-in PHP installations contain the most commonly used extensions. You ca
443447
444448
To enable other extensions, use the following steps:
445449

446-
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.
450+
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.
447451

448452
1. Deploy your changes.
449453

@@ -467,7 +471,7 @@ The built-in PHP installations contain the most commonly used extensions. You ca
467471
468472
To enable other extensions, use the following steps:
469473

470-
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.
474+
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.
471475

472476
1. Deploy your changes.
473477

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

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

505-
- [Access the log stream](#access-diagnostic-logs).
509+
- Access the [diagnostic log stream](#access-diagnostic-logs).
506510
- 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:
507511
- Depending on your `composer.json` file, different packages might be installed for production mode (`require` versus `require-dev`).
508512
- Certain web frameworks might deploy static files differently in production mode.

0 commit comments

Comments
 (0)