This script sets the appropriate permissions and ownership for a WordPress installation running under Nginx on Ubuntu.
-
Download and run the script using the following command:
wget https://raw.githubusercontent.com/egubaidullin/scripts/main/wp_rights.sh && sudo bash wp_rights.sh /path/to/wordpress
Replace
/path/to/wordpress
with the actual path to your WordPress installation directory. -
The script will set the ownership to
www-data:www-data
and adjust the permissions for directories and files as follows:- Directories:
755
- Files:
644
wp-config.php
:600
wp-content/uploads
,wp-content/plugins
, andwp-content/cache
directories:755
for directories and644
for files.
- Directories:
The script performs the following actions:
- Changes the ownership of all files and directories in the specified WordPress directory to
www-data:www-data
. - Sets permissions to
755
for all directories. - Sets permissions to
644
for all files. - Sets permissions to
600
for thewp-config.php
file. - Sets permissions to
755
for directories and644
for files in thewp-content/uploads
,wp-content/plugins
, andwp-content/cache
directories.