Azure App Service-How to use SSH Command to change Azure WordPress wp-content folder permission to 755

Stephen Wartel 60 Reputation points
2023-05-03T01:12:39.94+00:00

Having set up a WordPress web site using an Azure App Service, I checked the folder permissions. Looks like they need to be changed to 755, which is recommended. Tried FTP and changed permissions to 755 do not stay. Tried a WordPress plugin that can change these permissions, and while the plugin indicated successful permission change to 755, also this did not persist. As another option, signed in to my Azure subscription, as owner/global administrator, called up an SSH terminal, entered a suggested command (chmod 755 /home/site/wwwroot/wp-content), and again the change to 755 failed.

Not sure if this is the correct or complete SSH command needed? Would appreciate if someone can suggest the full and correct command that I need to enter in the SSH terminal to change each folder's permission to 755.

Or any other way to achieve this change in folder permissions.

Thank you for your help.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,405 questions
{count} vote

4 answers

Sort by: Most helpful
  1. Sedat SALMAN 13,345 Reputation points
    2023-05-03T20:32:06.6566667+00:00

    Can you provide the full error

    it can be probably permission error

    so you can go with sudo before command

    
    cd /home/site/wwwroot 
    
    sudo find ./wp-content -type d -exec chmod 755 {} \;
    
    
    

  2. Stephen Wartel 60 Reputation points
    2023-05-04T00:01:24.1266667+00:00

    Thank you for these suggestions.

    A beginner with Azure, I am not sure about the container, but I believe it is a docker container. Adding the "-R" to the command produced what appeared to be the terminal working on the change with recursion, but when completed, and I independently checked with an App Service's WP security plugin, I got the same result: wp-contents was still not set to 755.

    Again as a beginner, not sure how to find the "full error" but when I tried

    cd /home/site/wwwroot 
    
    
    

    I successfully CD'd to the directory, but then when I tried

    sudo find ./wp-content -type d -exec chmod 755 {} ;

    I got back:

    -ash: sudo: not found

    (I am using the Azure app service internal SSH terminal. Not sure I can install anything in it to resolve the sudo issue?)

    So no success yet, but hopefully this feedback may provide additional clues to what I am doing wrong, and additional suggestions to fix it.

    Best Wishes,


  3. Stephen Wartel 60 Reputation points
    2023-05-04T16:12:00.0366667+00:00

    I wonder if this is the problem?

    From: https://learn.microsoft.com/en-us/archive/blogs/waws/things-you-should-know-web-apps-and-linux#you-cannot-change-permissions-on-the-home-directory-when-persisting-storageapplies-to-web-app-for-containers

    You cannot change permissions on the /home directory when persisting storage.
    Applies to Web App for Containers

    When you persist storage with the WEBSITES_ENABLE_APP_SERVICE_STORAGE app setting, we mount a location in Azure Storage to the /home mount point. The permissions on this are 777. You cannot change these permissions, even if you attempt to do so from an initialization script or from SSH.


    The setting can be changed in the CLI to false (https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux&tabs=debian#use-persistent-shared-storage):

    az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=false

    Then the changes in permissions may possibly be accomplished in the Azure App Service's SSH terminal. Then the settings could hopefully be reversed to true?:

    az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=true

    Not sure however if this would not delete the sites contents, or do other "damage" to the site, causing need to rebuild it, or worse, need to start over, recreate the site?

    So, not going to try this possible (not sure it would even accomplish resetting permissions?) solution until fully learning what problematic consequences this can cause.

    Any suggestions would be appreciated.

    Thank you for your help.

    BTW the best reading I can get about the container is that it is a standard "single container"


  4. ajkuma 24,971 Reputation points Microsoft Employee
    2023-05-04T21:46:42.2733333+00:00

    Thanks for the follow-up and additional info. Apologies for any confusion, just to provide better understand the flavor of Azure App service,  you can have different flavor/version of WebApp, as follows:

    1.Code + Windows – You select the Application stack and deploy your code.

    2.Code + Linux (WebApp Linux) - App Service on Linux provides pre-defined application stacks on Linux with support for languages such as .NET, PHP, Node.js and others. These are blessed images, predefined by platform. Here you just deploy your code.

    3.Docker Container + Linux (WebApp for Container) – custom image (code already part of the image, and not deployed separately) - container image become containers at runtime.

    4.Docker Container + Windows (WebApp for Windows Container) – custom image – container image become containers at runtime.

     

    If you haven’t done already,    --Kindly checkout the process here - >>Enable diagnostics logging for apps in Azure App Service
    https://docs.microsoft.com/azure/app-service/troubleshoot-diagnostic-logs#access-log-files

     

    You can inspect the log files from Kudu console at https://yourwebsite.scm.azurewebsites.net/api/logs/docker, and fetch more details on the issue

     

    On either (code or container ) flavor -  As a best practice, you shouldn't install components using SSH because they won't persist.

     I understand you’re attempting to Azure WordPress wp-content folder permission to 755, could you please share more details about your scenario/requirement.

     

    I'll follow-up with you further.