I have a RHEL 7 machine running an Apache web server with multiple virtual hosts on it. I've recently run into an issue where I am unable to upload media, e.g. images / pictures / video, to my machine for applications such as a blog (WordPress) and a forum (XenForo). I've tried to check out what's going on and I can't seem to figure it out.
Both applications seem to share the same root problem. I've double-checked that the file permissions should be correct, yet I still run into the same errors.
$ ls -Alh total 8.0K -rw-rw-r--. 1 jflory apache 28 Sep 26 09:50 index.php drwxrwxr-x. 5 jflory apache 84 Oct 20 15:42 plugins drwxrwxr-x. 7 jflory apache 4.0K Sep 26 12:07 themes drwxr-xr-x. 2 jflory apache 6 Oct 20 15:42 upgrade drwxrwxr--. 3 jflory apache 17 Sep 26 11:40 uploads
“image.png” has failed to upload due to an error The uploaded file could not be moved to wp-content/uploads/2015/10.
$ ls -Alh ../public_html/ total 76K drwxrwxrwx. 7 jflory apache 96 Oct 11 20:19 data drwxrwxrwx. 6 jflory apache 4.0K Jul 19 02:57 internal_data
The following errors occurred while verifying that your server can run XenForo:
The directory /var/www/crystalcraftmc.com/public_html/data must be writable. Please change the permissions on this directory to be world writable (chmod 0777). If the directory does not exist, please create it.
The directory /var/www/crystalcraftmc.com/public_html/internal_data must be writable. Please change the permissions on this directory to be world writable (chmod 0777). If the directory does not exist, please create it.
Please correct these errors and try again.
I have double-checked that SELinux context is correct by running
sudo restorecon -Rv /var/www/. This has worked in the past, but this time, it was not the solution. HOWEVER, I have tried disabling SELinux with
sudo setenforce 0, restarted the Apache service, and this resolved the issue. It seems like SELinux is to blame, but I unsure as to why, and I don't wish to keep it disabled.
I am completely lost about what the issue can be - none of this makes sense. If any further information is needed, please ask me for clarification.