Issue with setting the proper permissions for our WordPress

Altina Hoti 0 Reputation points
2025-03-17T12:37:30.34+00:00

We are currently facing an issue with setting the proper permissions for our WordPress installation located at /var/www/wordpress on our Web App - Azure server.

We are attempting to set the following permissions using the following commands:

chown www-data:www-data -R * (to let Apache/nginix be the owner)

find . -type d -exec chmod 755 {} ; (to change directory permissions to rwxr-xr-x)

find . -type f -exec chmod 644 {} ; (to change file permissions to rw-r--r--)

However, we are unable to apply these changes successfully. Could you kindly assist us in troubleshooting this issue and provide any guidance on how we can resolve it?

Thank you for your support.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bhargavi Naragani 5,270 Reputation points Microsoft External Staff Moderator
    2025-03-17T21:16:31.77+00:00

    Hi @Altina Hoti,

    It seems like you're facing difficulties while setting the correct permissions for your WordPress installation located at /var/www/wordpress on our Web App - Azure server.

    It is important to set the correct file and directory permissions for the security and operation of your WordPress site. Directories are usually 755 permissions (rwxr-xr-x), where the owner can read, write, and execute, and others can read and execute. Files should be 644 permissions (rw-r--r--), with the owner being able to read and write, and others able to read. These files and directories should be owned by the web server user (usually www-data for Apache/Nginx) to function properly.

    If directories and files are owned by root or another user, the web server might not have the permissions to read or write, causing problems such as plugin update failure or FTP password prompts. To fix this, you can change ownership by running below command recursively gives ownership to the www-data user and group to all files and directories in /var/www/wordpress:

    sudo chown -R www-data:www-data /var/www/wordpress
    

    After correcting ownership set the appropriate permissions:

    To set 755 for all directories:

    find /var/www/wordpress -type d -exec chmod 755 {} \;
    

    To set 644 permissions for all files:

    find /var/www/wordpress -type f -exec chmod 644 {} \;
    

    These commands ensure that directories and files with proper permissions, improving security and functionality.

    In case WordPress asks for FTP credentials when updating, it may be a sign of lacking permissions. To enable direct access, include the following line in your wp-config.php file, this parameter allows WordPress to directly edit files without needing FTP credentials.

    define('FS_METHOD', 'direct');
    

    Kindly refer to the below links:
    https://developer.wordpress.org/advanced-administration/security/hardening/
    https://developer.wordpress.org/advanced-administration/server/file-permissions/
    https://stackoverflow.com/questions/18352682/correct-file-permissions-for-wordpress

    If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.

    Let me know if you have any further Queries.

    0 comments No comments

  2. Altina Hoti 0 Reputation points
    2025-03-18T09:03:14.48+00:00

    Hi @Bhargavi Naragani
    Thank you for your detailed response and guidance. I truly appreciate your help.

    I have followed all the suggested steps, including changing ownership to www-data:www-data and setting the correct permissions using the find commands. However, despite these changes, I am still unable to modify wp-content. It remains set to 777, and I am not allowed to change it, even when using the appropriate commands.

    To provide more context, I have attached three screenshots that illustrate the issue I am facing. Could you please assist me in identifying why I am unable to apply these changes and how I can resolve this issue?

    I appreciate your support and look forward to your guidance.
    1 SSH

    2 SSH

    3 SSH


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.