Unable to load media through Wordpress downloader

This is due to media download in Wordpress.

Each time WP creates a folder for new downloads (it organizes downloads by year and month: yyyy / mm), it creates it with the user and the "apache: apache" group with full access to everyone (777 or drwxrwxrwx ).

However, after that, WP cannot create a folder inside this folder (for example: mkdir 2011 succeeds, but mkdir 2011/01 does not work). In addition, the download cannot be moved to these newly created folders, even if the permissions are 777 ( rwxrwxrwx ).

Once a month, I should chown newly created folders to be the same as the user: group, like the rest of the files. As soon as I do this, the download stops working (which makes no sense to me. The really disappointing part is that this problem does not exist in other WP installations in other domains on the same server.

* I was not sure what it should be here or on the server.


Edit: the containing directory /.../httpdocs/blog/wp-content/uploads has the correct ownership

 drwxrwxrwx 5 myuser psaserv 4096 Jun 3 18:38 uploads 

This is the Plesk / CentOS environment hosted by Media Temple (dv).

I wrote the following test script to simulate a problem

 <pre><?php $d = "d" . mt_rand(100, 500); var_dump( get_current_user(), $d, mkdir($d), chmod($d, 0777), mkdir("$d/$d"), chmod("$d/$d", 0777), fileowner($d), getmyuid() ); 

The script always creates the first mkdir($d) directory successfully. In domain A, where WP is a problem, it cannot create the mkdir("$d/$d") . However, in domain B, both directories have been successfully created.

I run each script in /var/www/vhosts/domainA/httpdocs/tmp/t.php and /var/www/vhosts/domainB/httpdocs/tmp/t.php respectively, I checked permissions on tmp , httpdocs and domain[AB] , and they are the same for every path. The only thing that is different is the user.

+6
upload wordpress permissions
source share
9 answers

Try going to the page with different settings (or media depending on your version) and make sure that the download directory is still in wp-content / uploads.

If you need. set the full url too.

Also, as a final solution, disable the ability to organize them into folders so that WordPress does not even need to create folders.

+2
source share

The solution is to use FastCgi. This makes PHP work as the user who owns the site. New files and folders will be the same users and groups. This will solve your problem.

There is a performance penalty for FastCgi, but you get some extra security as it limits php. If you host multiple websites with multiple users, this might be a good idea.

+3
source share

Check the setuid or setgid bit in the directory above the 2010 directory. ls -l will have s or S in directory permissions. Make sure that this directory has the correct ownership.

+1
source share

Try creating a recursive directory with mkdir($d, true)

 <pre><?php $d = "d" . mt_rand(100, 500); var_dump( array( get_current_user(), $d, mkdir($d,true), chmod($d, 0777), mkdir("$d/$d", true), chmod("$d/$d", 0777), fileowner($d), getmyuid() ) ); 
+1
source share

I recently had a similar problem with Joomla, and I solved the problem by adding myuser to the apache group and adding apache to the psaserv group.

+1
source share

One of our websites at Media Temple DV had this problem. Disabling PHP Safe Safe Mode. Directories were still created as apache: apache, but media files were allowed there.

+1
source share

One thing that happened to me - WP will tell you that it cannot copy the file to /wp-content/upload , even if all rights are right ... if

upload_max_filesize

in php.ini too small (say 2M and you are trying to download a 3.5MB file)!

Hope this helps all those who have access rights but still cannot download!

+1
source share

You do not need 777 in your directories, a maximum of 775 should be enough. Just make sure it is installed in the uploads directory with 755 for all other directories above.

In addition, you can try to use it for www-data, sometimes it helps when your ftp user with whom you are logged in, as when changing permissions once a month, does not have sufficient access level and owns the directories of this user prevents the possibility server entries in them.

Finally, as someone pointed out above, you may need to set a limit on the size of the download, in order to make sure that the other php.ini settings for downloading files are correct:

http://php.net/manual/en/ini.core.php

http://kb.mediatemple.net/questions/137/How+can+I+edit+the+php.ini+file%3F#dv

+1
source share

One of the common reasons often overlooked is disk quota, that is, you have run out of disk space.

+1
source share

All Articles