This post provides information on how to setup a custom php runtime for Azure App Service Windows.
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.inifile 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
- Add a
bindirectory to your root directory, and put the directory that contains your PHP runtime in it (for example,
- 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
*.phpto the Extension field and add the path to the
php-cgi.exeexecutable. If you put your PHP runtime in the
bindirectory in the root of you application, the path will be
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.
To validate if the custom php version is being executed, you can create a quick info page with the following code: