WordPress file permissions Safe values ​​for are certain: folders should be 755, files should be 644, wp-config.php should be 600 or 640. These values ​​give enough permission for the site to run and prevent anyone else from writing files. When the 777 permission given to overcome an installation problem is forgotten, it becomes one of the most common security vulnerabilities.

What do permission figures mean?

The first digit of the three-digit value describes the file owner, the second describes the group, and the third describes everyone else. Each digit is the sum of read (4), write (2) and execute (1) rights. 644 owners read and write, the others read alone. The owner with a value of 755 does everything, the others read and enter the folder.

Elementcorrect valuerisky valueRisk
folders755777Anyone can drop files into the folder
files644666File content can be changed externally
wp-config.php600 or 640644 and aboveDatabase password can be read by other accounts
.htaccess644666Routing rule can be added

How do you check existing permissions?

In the file manager of the hosting panel, there is a permission column next to each file. You can right-click on the file in the FTP program and open the File Permissions option. The Site Health screen under Tools in the WordPress panel also lists writable folders on the Information tab. If you have SSH access, you can find items with 777 permissions with one command:

find . -perm 777
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod 600 wp-config.php

The first line lists everything with 777 permissions. The second and third line pulls folders and files to the correct value. The last line makes the configuration file readable only by the owner. Run the commands in the root of the site; If you run it in a higher directory, it will affect other sites in your account.

Lines to add to wp-config.php file

This file carries the database name, user and password. Besides the permission value, these lines also increase security:

  • define( 'DISALLOW_FILE_EDIT', true ); Turns off theme and plugin file editing from the panel. Even if the administrator account is compromised, code cannot be added from the panel.
  • define( 'FORCE_SSL_ADMIN', true ); It opens the administration panel only over HTTPS.
  • Renew security keys (AUTH_KEY and others) from WordPress's official key generator. When the keys are changed, all open sessions are closed.

The place of these settings in the entire security work WordPress security optimisation You can see it in our guide.

Turn off running PHP in uploads folder

The Downloads folder must be writable because the images are saved there. However, file PHP does not need to work in this folder. On servers using Apache, you can turn off PHP execution by adding a .htaccess file to the folder:

<FilesMatch "\.php$">
  Require all denied
</FilesMatch>

This rule denies access to files with .php extension in the folder. Images and documents are not affected. On servers using Nginx, the hosting company adds the same rule to the server configuration.

Example scenario

For example, on a corporate site, since the plugin installation gave an error, 777 permission was given to the wp-content folder and left that way. Months later, a PHP file with the image name appears in the uploads folder and the site starts redirecting to other addresses. After the cleaning, the permissions are set to 755 and 644, and PHP is closed in the uploads folder. The same vulnerability cannot be used again.

Things to consider in shared hosting

Most shared hosting packages from Türkiye work with the user of your account PHP. In this structure, values ​​755 and 644 are sufficient for updating and loading. If the installation or update gives the error "could not write the file", the solution is not to set the permission to 777, but to correct the file ownership. Open a support ticket with the hosting company and request that the ownership be adjusted according to your account.

Common mistakes

  • Give 777 to solve the problem: The error goes away but the folder is opened to everyone.
  • Fixing permissions on root directory only: Subfolders remain at their old value; The command must also include subdirectories.
  • Leaving the wp-config.php backup in the root directory: Files such as wp-config.php.bak are read from the browser as plain text.
  • Not checking permissions after cleanup: Permissions are often changed on sites infected with malicious code.

Work where permissions, configuration and server rules are considered together WordPress security optimization service You can review it on our page.

Why is 777 permission dangerous?

A value of 777 gives everyone on the server read, write and execute rights. Another account on the same server or an open plugin can drop files into this folder.

I corrected the permissions but cannot update. From where?

The owner of the files may be different from the user under whom PHP is running. Ask the hosting company to correct the file ownership according to your account.

Does moving the wp-config.php file to a higher folder help?

WordPress also finds the file one level above the root directory. If you can write to this folder on shared hosting, the file has been moved to a location that cannot be accessed via the web.