0

When I go to upload a file to my WordPress site, I get the following error:

Unable to create directory wp-content/uploads/2017/03. Is its parent directory writable by the server?

I am running WordPress on an Apache 2.2.2 server, on a Linux machine. The wp-content folder has 775 permissions, and I created a /uploads folder inside also with 775 permissions. The user and group for both of these folders, and for the entire WordPress file directory, is www-data.

I am running WordPress 4.7.3.

If this is noteworthy, upon installation, my upload_path variable was not set. I have since set it to wp-content/uploads and manually created the uploads directory with 775 permissions.

The process of installation was to install using wget wordpress.org/latest.tar.gz and install it from there.

Could this have something to do with it?

No solutions found on the net involving changing permissions, or setting php to unsafe mode, have worked.

Cheers!

EDIT:

Might other files and directories not being owned and grouped by www-data have anything to do with this? ls -l makes this:

-rw-r--r-- 1 nobody nogroup 418 Sep 24 2013 index.php -rw-r--r-- 1 nobody nogroup 19935 Jan 2 12:51 license.txt -rw-r--r-- 1 nobody nogroup 7433 Jan 11 11:46 readme.html -rw-r--r-- 1 nobody nogroup 5447 Sep 27 16:36 wp-activate.php drwxr-xr-x 9 nobody nogroup 4096 Mar 6 10:00 wp-admin -rw-r--r-- 1 nobody nogroup 364 Dec 19 2015 wp-blog-header.php -rw-r--r-- 1 nobody nogroup 1627 Aug 29 2016 wp-comments-post.php -rw-r--r-- 1 root root 3045 Mar 22 21:47 wp-config.php -rw-r--r-- 1 nobody nogroup 2853 Dec 16 2015 wp-config-sample.php drwxrwxr-x 5 www-data www-data 4096 Mar 22 23:09 wp-content -rw-r--r-- 1 nobody nogroup 3286 May 24 2015 wp-cron.php drwxr-xr-x 18 nobody nogroup 12288 Mar 6 10:00 wp-includes -rw-r--r-- 1 nobody nogroup 2422 Nov 20 20:46 wp-links-opml.php -rw-r--r-- 1 nobody nogroup 3301 Oct 24 22:15 wp-load.php -rw-r--r-- 1 nobody nogroup 33939 Nov 20 20:46 wp-login.php -rw-r--r-- 1 nobody nogroup 8048 Jan 10 23:15 wp-mail.php -rw-r--r-- 1 nobody nogroup 16250 Nov 28 23:39 wp-settings.php -rw-r--r-- 1 nobody nogroup 29896 Oct 18 23:47 wp-signup.php -rw-r--r-- 1 nobody nogroup 4513 Oct 14 14:39 wp-trackback.php -rw-r--r-- 1 nobody nogroup 3065 Aug 31 2016 xmlrpc.php

2 Answers2

0

Most likely the real problem are permissions, and probably you didn't fully change them as needed or the webserver is running it as a different user than you expect.

I would test it out using sudo like this (replace /var/www with the relevant path):

sudo -u www-data mkdir -p /var/www/wp-content/uploads/2017/03

If that is working, I would check "dmesg" for AppArmor failures though I don't believe that AppArmor is blocking apache2/php by default from memory.

If that is not working, I would use that as a simple test to explore and fix the permissions to work. You could start by checking all directory levels permissions

ls -lad /var/www /var/www/wp-content /var/www/wp-content/uploads /var/www/wp-content/uploads/2017 /var/www/wp-content/uploads/2017/03
Trent Lloyd
  • 384
  • 1
  • 8
0

Well, I sure do feel like a Dunder-Mifflin.

Checked the running processes by using ps aux | egrep '(apache|httpd)' and noticed all processes were running under http-web. I confirmed through ls -l that my permissions in all of my WordPress folders were for some www-data user and group.

I changed all of that using chown -R http-web:http-web /var/www/html (I have an extra html folder inside of www).

Sources:

https://stackoverflow.com/questions/19020186/the-uploaded-file-could-not-be-moved-to-wp-content-uploads

Use chown to set the ownership of all a folder's subfolders and files?