I always upload my WordPress files on the server so the “owner” is my username and I can change the permission to, let’s say, 770. But when I install a plugin, the owner becomes “www-data” and the permission is rw-r-xr--
. However, I need to modify some files. Can I do something in the WordPress config to change the generated file’s default permissions? I’m not the server’s root. Thank you.
Leave a Reply
You must be logged in to post a comment.
Its simple please see
https://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions
It is as below::
Override of default file permissions
The FS_CHMOD_DIR and FS_CHMOD_FILE define statements allow override of default file permissions. These two variables were developed in response to the problem of the core update function failing with hosts (e.g. some Italian hosts) running under suexec. If a host uses restrictive file permissions (e.g. 400) for all user files, and refuses to access files which have group or world permissions set, these definitions could solve the problem. Note that the ‘0755’ is an octal value. Octal values must be prefixed with a 0 and are not delineated with single quotes (‘).
Example to provide setgid:
If you want to change file permissions see
https://codex.wordpress.org/Changing_File_Permissions
EDIT:
Put these after putting any of the above code:
Here is the correct file permissions for WordPress:
Depending on your server configuration you may put your
wp-content
on775
. This permission will allow your group to write in this folder. Why add group permissions? Because in wordpress, you can have two users working on files, thewww-data
user (who executes the website) and theftp user
(who downloads plugins and updates from the webplatform wordpress). You can put yourwp-content
on755
but you have to makewww-data
the owner of this folder and do your updates manually via FTP.Learn more about wordpress File Permissions