Skip to content

Latest commit

 

History

History
68 lines (46 loc) · 3.02 KB

wordpress_adding_php_extensions.md

File metadata and controls

68 lines (46 loc) · 3.02 KB

Adding PHP extensions for WordPress Linux App Services

Customers who need to install PHP extensions that are not available on the WordPress Linux App Services image can do so by following the below steps. Here we will take an example and show how to add soap extension for PHP version 8, and please note that the process would be similar for other extensions.

Installing PHP Extensions

  1. Open an SSH session using WebSSH from the Azure portal. Web SSH

  2. Find out the PHP version of your WordPress image using the below command.

    php -v
  3. Install soap extension for PHP.

    Note: Depending on the version of the PHP, the name of the package needs to be updated accordingly. Additionally, you can use the Alpine Linux Packages dashboard to search for your required PHP extensions. You can make use of wildcards (* and ?) in the search.

     apk update
     apk add php8-soap
  4. For PHP 8, the extensions will be installed under /usr/lib/php8/modules/. If you are not able to find it, you can make use of find command to locate the extension file.

    cd /
    find . -name 'soap.so'
  5. Now that the extension is installed, you need to create an ext directory under /home/site/ and copy the extension file to it. This is because changes made outside /home path are non-persistent in nature and will be reset to the default state when the container is restarted.

     mkdir -p /home/site/ext
     cp /usr/lib/php8/modules/soap.so /home/site/ext/soap.so
  6. Then we need to create a extensions.ini file under /home/site/ini directory and add the extension configuration to it.

     mkdir -p /home/site/ini
     echo 'extension=/home/site/ext/soap.so' >> /home/site/ini/extensions.ini
  7. Go to your App Service in Azure Portal and add the following Application Settings. You will find Application Settings under Settings -> Configurations blade. Once the below settings are added, click on save. This will restart your Web App and new changes should be reflected.

    Application Settings Name Value
    PHP_INI_SCAN_DIR /usr/local/etc/php/conf.d:/home/site/ini

Testing

  1. To test whether the extension is enabled or not, you can create a phpinfo.php file under /home/site/wwwroot/ directory and add the code <?php phpinfo(); to it. You can make use of the below command to do so.

    echo "<?php phpinfo();" > /home/site/wwwroot/phpinfo.php

    You should now see the extension is enabled by going to https:\\<sitename>.azurewebsites.net/phpinfo.php

  2. Do not forget to remove the phpinfo.php page once you’re done using it.

    rm /home/site/wwwroot/phpinfo.php

Additional References: