Permission set on upgrading your wordpress site on RHEL7.

This article will show you how to set proper permission when upgrading your wordpress site with latest version.

Update folder permission to allow wordpress download and write files

To use wordpress auto upgrade feature, you’ll need to give permission to your wordpress server admin account, eg, if you use nginx as web server, you’ll need to grant nginx user admin access to download and write files on your site .

# Check if nginx user has write access to wp-amdin/wp-includes folders, below use /usr/share/nginx/html/your-site as an example
ll /usr/share/nginx/html/your-site/ -Z

# Example output
drwxr-xr-x. nginx nginx unconfined_u:object_r:httpd_sys_content_t:s0 wp-admin

Above indicates that the “wp-admin” folder only has read only access, once you try to upgrade from wordpress dashboard, it fails with permission insufficient error. To fix it, run below command to grant write access

# Grant write access
sudo chcon -t httpd_sys_rw_content_t /usr/share/nginx/html/your-site/wp-admin/ -R
# Now check again
ll /usr/share/nginx/html/your-site/ -Z

# Your should see something like below, means you grant write to that folder
drwxr-xr-x. nginx nginx unconfined_u:object_r:httpd_sys_rw_content_t:s0 wp-admin

You can now go to wordpress dashboard and try to upgrade your wordpress version, if same permission error happens but for other folder, give those folders or files write permission

Rollback write permission to those folders/files that only need read access.

# Grant read only access
sudo chcon -t httpd_sys_content_t /usr/share/nginx/html/your-site/wp-admin/ -R

 

 

Scroll to Top