Blog Post

Apps on Azure Blog
2 MIN READ

Updating NGINX default configurations on Azure App services Managed WordPress

karthi's avatar
karthi
Icon for Microsoft rankMicrosoft
Jan 06, 2023

Azure App services Managed WordPress is a new service offering provided by Microsoft Azure to host WordPress websites. It runs on a Linux machine and the technology on which this Managed WordPress site runs is PHP and the web server it uses is NGINX.

 

 

 

In this blog post, you will understand on how you can modify the default configurations of NGINX on Managed WordPress site on Azure app services.

 

On that note, let's quickly deep dive into the technical aspects of modifying the default configurations on Azure app service Managed WordPress website.

 

Now, let us quickly navigate to the Azure portal --> App service (Managed WordPress) --> click on SSH blade, this would take you to the WebSSH console.


This would open an SSH session for you as below and you can navigate to the path /etc/nginx/conf.d where you can find the file default.conf as shown below.

 

 

Commands to navigate:

  • cd /etc/nginx/conf.d
  • ls -lrt

 

And this default.conf has all the necessary location routes and other serve specific details, sample configuration in default.conf is as below,

 


 

Now, as a next step, you can copy this default.conf to /home which is a persistent storage on Azure app services.

 

Command:

  • cp /etc/nginx/conf.d/default.conf /home/default.conf

 

Now you can navigate to this default.conf file under /home

 


 

Command:

  • cd /home

 

To modify the default.conf file open with any editor like vim/vi,

 

Command:

  • vi /home/default.conf

 

You can make necessary changes to this default.conf file now and save it by giving [ESC + : + wq+ ENTER (KEY)]

 

Once saved, we need to create a startup script to tell NGINX to update this default.conf which is present in /home to /etc/nginx/conf.d. To create a startup script, you can follow the below steps.

 

Inside SSH -> /home/dev -> create a file -> command: touch startup.sh [If you have the startup.sh already, you can append the commands to the same file] 

 

Now open that file using vi editor as -> vi startup.sh and provide the below content inside startup script

 


 

The first line will copy the configurations and the second line will reload the NGINX.

To run this bash script while starting the container, you can follow the steps outlined here - How to run Bash scripts in WordPress on Azure App Service - Microsoft Community Hub

 

Happy Learning!!!

Updated Sep 15, 2023
Version 4.0
  • folio1's avatar
    folio1
    Copper Contributor

    HIi karthi 
    Thanks for your reply...
    So you should be able to run the startup script within the StartUp Command field or is this still a issue on it being ignored?

    Note on the following link
    https://github.com/Azure/wordpress-linux-appservice/blob/main/WordPress/running_post_startup_scripts.md

    Note: As of September 2022, the startup script MUST exist at (/home/dev/startup.sh). Further, the value of the Startup Command field in the Azure Portal found under [App Service for Linux] > Configuration > General Settings > Startup Command is ignored. The Azure team is aware of this and working to make this flow more natural.

  • folio1's avatar
    folio1
    Copper Contributor

    Is this based on the wordpress-alpine-php:8.2 container image?
    mcr.microsoft.com/appsvc/wordpress-alpine-php:8.2