0

I have a centOS -based virtual machine on digital ocean. It is running NGINX HTTP sever. I configured it to use multi domains, and set up SSL.

One of my domains runs a Wordpress application. I migrated the WordPress files from my godaddy hosting.

Everything works great except when I try to upgrade the wordpress core ( updating and installing plugins works just fine).

When I try to upgrade WordPress to version 5.4.2 I get a permissions error (as shown in attachment photo):

Permission denied in /var/www/mydomain.com/wordpress/wp-admin/includes/class-wp-filesystem-direct.php on line 281

wordpress core upgrade file permissions error display

I tried doing the following just to diagnose the issue... I have the directory full access to nginx user: chmod -R 777 /var/www/

chown nginx:nginx /var/www/

This did not work

I made sure php user is nginx by outputting echo exec('whoami'); on the page.

I am completely dumbfounded. Does anyone know what the problem may be?

As a last resort I manually upgraded my wordpress version using FTP, but I'm concerned that I never figured out the root cause of this issue and it will spring back up again opening up a can of worms.

1
  • @esqew wow that fixed it! Thank you! (there was a typo though that I had to edit) sudo chcon -R --type=httpd_sys_rw_content_t /var/www/mydomain.com Commented Aug 6, 2020 at 18:36

1 Answer 1

1

CentOS includes a mandatory access control (MAC) security mechanism in its Linux kernel by the name of SELinux. According to a support forum thread on Wordpress.org, this mechanism sometimes can cause issues that manifest with this error.

SSH into your server and use the following command to change the SELinux "context" for the entire /var/www/mydomain.com folder:

chcon -R –-type httpd_sys_rw_content_t /var/www/mydomain.com/ 

The last post in the above-linked thread indicated that this change of context alleviated the errors you're seeing.

As an aside, for your system's security, ensure you change your file permissions back to their defaults.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.