How to use a Custom PHP runtime for App Service Windows
This post provides information on how to setup a custom php runtime for Azure App Service Windows.
Configuration
Instead of the default PHP runtime, App Service Web Apps (Windows) can use a PHP runtime that you provide to execute PHP scripts. The runtime that you provide can be configured by a php.ini
file that you also provide. To use a custom PHP runtime with Web Apps, follow the steps below.
- Obtain a non-thread-safe, VC9 to VC16 compatible version of PHP for Windows. Recent releases of PHP for Windows can be found here: http://windows.php.net/download/. Older releases can be found in the archive here: http://windows.php.net/downloads/releases/archives/.
- Modify the
php.ini
file for your runtime. Note that any configuration settings that are system-level-only directives will be ignored by Web Apps. (For information about system-level-only directives, see List of php.ini directives). - Optionally, add extensions to your PHP runtime and enable them in the
php.ini
file. - Add a
bin
directory to your root directory, and put the directory that contains your PHP runtime in it (for example,bin\php
). - Deploy your web app.
-
Browse to your web app in the Azure Portal and click on the Configuration button.
-
From the Configuration blade select Path mappings and go to the Handler mappings section. Add
*.php
to the Extension field and add the path to thephp-cgi.exe
executable. If you put your PHP runtime in thebin
directory in the root of you application, the path will beC:\home\site\wwwroot\bin\php\php-cgi.exe
. -
Click the Save button at the top of the Configuration settings blade. And then click on Continue.
For additional configurations for running Composer or any popular automation tool at deployment time, review this reference.
Validation
To validate if the custom php version is being executed, you can create a quick info page with the following code:
<?
phpinfo();