Check and Change PHP Version in Azure WordPress on Linux

I’ve been testing setting up WordPress on Linux as an Azure Web App. Checking and setting the PHP version has been quite a challenge. Here’s how I finally got it working.

I first set up a WordPress on Linux app in West US 2 using a P1v2 app service plan and a Basic database:

WordPress PHP 1

You’re supposed to be able to see and change the PHP version from the Azure app under Setting > Configuration > General Settings, but that didn’t show anything about PHP:

WordPress PHP 4

At this point, following this document, I checked the PHP version and learned that it is “DOCKER|appsvcorg/wordpress-alpine-php:0.72” (which makes no sense to me):

WordPress PHP 2

I confirmed this by removing the --query parameter so I could see the entire configuration. The linuxFxVersion is is about halfway down in the results:

WordPress PHP 3

I found that I could set the PHP version using the command in the same document.

Note The show and set commands have different syntax. Show uses --query linuxFxVersion where as set uses --linux-fx-version (which must be lowercase). Thanks to RoderickBant74 for leading me through that confusion in this thread.

WordPress PHP 5


WordPress PHP 6

Now the show works as expected:

WordPress PHP 7

And the PHP version appears in the UI as well:

WordPress PHP 8

It would have saved a lot of time If that had been in the UI in the first place!

I suspect this is a misconfiguration in the WordPress image. Until that is fixed, use the command line to set PHP once, then you should be able to control it from the UI.

Update January 10, 2021

A Microsoft rep responded in two places regarding this issue. Be sure to review those replies:

As I noted in my November 20, 2020 comment on the Github issue:

Thank you for the referral to the WordPress on Azure Docker site, which I followed to its Github pages. For some reason, the critical “how to” .md files are not displayed in the Azure marketplace, but I learned enough to realize that I probably need to abandon this image. For example, they recommend against doing a major version upgrade to WordPress inside the container because they do not use persistent storage. Issues are not receiving much attention. The 0.8 branch was last updated two years ago. The 0.9 branch, updated 4 months ago, is not even listed in Docker. In fact, the entire project, in spite of over 1 million downloads, seems almost dead. It’s surprising that such a popular project with is just allowed to languish, and that Microsoft would not offer an official option for hosting WordPress.

I’m not sure I ever understood whether changing the PHP version really loaded a new Docker image. However as noted, I didn’t feel that it would be wise to use an image that is not well maintained, and I was also concerned about the lack of persistent storage. I decided instead to create a new Ubuntu 20.04 virtual machine, this time based on an image from OpenLiteSpeed. Once I resolved a security concern, the image seems pretty good and easier to set up than Bitnami. The CyberPanel product from the same company looks promising as well.

7 thoughts on “Check and Change PHP Version in Azure WordPress on Linux

  1. Jack

    Hi Mark, thanks for sharing this great info. I have a question and wonder if you could shed some light.
    I have a production WordPress running on Azure just like your test setup and I am wondering if upgrading PHP will break the database? Thanks a bunch :)

  2. Mark Berry Post author

    @Jack, I don’t know. In general, I would think that PHP would not affect the MySQL database, but it could break plugins or the theme that you are using in WordPress. Also, there is some confusion about why the info in this post works. See the comments from Microsoft at the end of this thread, where they recommend using a different image:

    I gave up on using WordPress in a container and am using an OpenLiteSpeed image instead.

  3. Jack

    Thanks for reply to my question and thanks for sharing further relevant info. Greatly appreciated it :)

  4. Mark Berry Post author

    Jack, I’ve posted an update to the main post above with more information and links. Thanks for reminding me to get this post updated!

  5. Jack

    Hello Mark, thanks again for the updates and a huge thank you for sharing that you’ve migrated to OpenLiteSpeed image. I spent today testing it out and found it to be quite rebust and well maintained. Thus, we decided to migrate our production WP to OpenLiteSpeed image as well :)

    Thanks again for sharing so much great info. I enjoy your blog posting and I am sure many others find them to be very informative as well :)

  6. Mark Berry Post author

    @Jack, I’m glad you found the information helpful. You might also look at CyberPanel Enterprise. I haven’t tested it yet, but I think it’s free for one domain (might be limited to 2GB memory) and includes standard LiteSpeed, with some enhancements over OpenLiteSpeed.

  7. Karim

    Thank you for this mate! VERY helpful!

    I’d like to add my 2 cents in the hopes it may help someone.
    For some reason when I used the az webapp config show command with the –resource-group parameter, I would get a resource group not found error (yes I switched the subscription context and the get-azresourcegroup would display the resource group with the correct name).

    An alternative is to use the webapp’s resource ID with the command az webapp config show and the command az webapp config set and you don’t need the resource group name or the webapp’s name either.

    So, instead of:
    az webapp config show –resource-group –name –query linuxFXVersion
    az webapp config show –ids

    and, instead of:
    az webapp config set –resource-group –name –linux-fx-version “PHP|7.4”
    az webapp config set –ids –linux-fx-version “PHP|7.4”

    You can find the resource id in the Properties blade of the webapp.

    Hope this helps someone!

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.

This site uses Akismet to reduce spam. Learn how your comment data is processed.