Tuesday 6 November 2018

linux - Wordpress can't upload images due to permissions



I'm having problems trying to get Media uploads working on my VPS w/ Wordpress. My Apache service is running as user:group apache:apache. My user folder is owned by my user eugene and grouped apache. I can load my Wordpress site but I cannot get any media uploads to work. Every file/folder has rwx for the user and group level.


I get the error:



The uploaded file could not be moved to wp-content/uploads.

What am I doing wrong? Or am I setting this up the wrong way?



[eugene@myvps ~]$ pwd
/home/eugene
[eugene@myvps ~]$ ll
total 0
drwxrws---. 3 eugene apache 24 Dec 11 09:58 public_html
[eugene@myvps ~]$ cd public_html/
[eugene@myvps public_html]$ ll
total 0
drwxrws---. 3 eugene apache 16 Dec 11 09:58 website.com
[eugene@myvps public_html]$ cd website.com/
[eugene@myvps website.com]$ ll
total 4
drwxrws---. 5 eugene apache 4096 Dec 11 13:53 www
[eugene@myvps website.com]$ cd www
[eugene@myvps www]$ ll
total 7100
-rwxrws---. 1 eugene apache 418 Sep 24 2013 index.php
-rwxrws---. 1 eugene apache 7079339 Dec 11 09:58 latest.tar.gz
-rwxrws---. 1 eugene apache 19930 Jan 1 2015 license.txt
-rwxrws---. 1 eugene apache 7358 Dec 3 08:46 readme.html
-rwxrws---. 1 eugene apache 169 Dec 11 12:10 test.php
-rwxrws---. 1 eugene apache 5035 Oct 6 14:56 wp-activate.php
drwxrws---. 9 eugene apache 4096 Dec 11 11:51 wp-admin
-rwxrws---. 1 eugene apache 271 Jan 8 2012 wp-blog-header.php
-rwxrws---. 1 eugene apache 1369 Oct 3 07:47 wp-comments-post.php
-rwxrwx---. 1 eugene apache 3103 Dec 11 13:52 wp-config.php
-rwxrws---. 1 eugene apache 2764 May 9 2015 wp-config-sample.php
drwxrws---. 5 eugene apache 63 Dec 11 10:36 wp-content
-rwxrws---. 1 eugene apache 3286 May 24 2015 wp-cron.php
drwxrws---. 16 eugene apache 8192 Dec 8 15:45 wp-includes
-rwxrws---. 1 eugene apache 2380 Oct 24 2013 wp-links-opml.php
-rwxrws---. 1 eugene apache 3316 Nov 5 15:59 wp-load.php
-rwxrws---. 1 eugene apache 33710 Nov 6 14:36 wp-login.php
-rwxrws---. 1 eugene apache 7887 Oct 6 07:07 wp-mail.php
-rwxrws---. 1 eugene apache 13021 Nov 19 23:24 wp-settings.php
-rwxrws---. 1 eugene apache 28594 Oct 30 01:52 wp-signup.php
-rwxrws---. 1 eugene apache 4035 Nov 30 2014 wp-trackback.php
-rwxrws---. 1 eugene apache 3061 Oct 2 15:46 xmlrpc.php
[eugene@myvps www]$ cd wp-content/
[eugene@myvps wp-content]$ ll
total 4
-rwxrws---. 1 eugene apache 28 Jan 8 2012 index.php
drwxrws---. 3 eugene apache 52 Dec 8 15:45 plugins
drwxrws---. 5 eugene apache 83 Dec 8 15:45 themes
drwxrws---. 2 eugene apache 6 Dec 11 11:59 uploads
[eugene@myvps wp-content]$

I even went as far as giving wp-content 777, but still getting the same error. :(


Any help is greatly appreciated, thanks!



Answer



Well, after banging my head on my desk and /face_through_desk. I figured it out.


SELinux to the rescue! Or not...


I ran into this article which goes over configuring SELinux for Wordpress uploads: How to allow WordPress to upload images on an SELinux enabled server


Ultimately I ran:



chcon -t tmp_t uploads

And was able to keep my permissions as so... everything works now. Hope this can help someone else down the road. "CentOS was such a better idea vs Debian"


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...