Updating NGINX default configurations on Azure App services Managed WordPress

Posted by

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.

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.

 

karthi2210_0-1672983330593.png

 

 

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.

karthi2210_0-1672982804054.png

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.

 

karthi2210_1-1672982804055.png

 

Commands to navigate:

  • cd /etc/nginx/conf.g
  • 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,

 

karthi2210_2-1672982804056.png

 

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

 

karthi2210_3-1672982804057.png

 

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 -> create a file -> command: touch startup.sh

 

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

 

karthi2210_4-1672982804058.png

 

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!!!

Leave a Reply

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

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