WordPress: Could not create directory – Plugin Install Failed
by admin on Feb.10, 2010, under Wordpress
This error appeared every time I wanted to install a plugin automatically, even in the current version (2.9.1) of WordPress:
Downloading install package from http://downloads.wordpress.org/plugin/sample-plugin.zip.
Unpacking the package.
Installing the plugin.
Could not create directory. /var/www/html/web999/blog/wp-content/plugins/sample-plugin/
Plugin Install Failed.
This is caused by an error when running the php function mkdir() under safe_mode on certain versions of PHP (I’m using PHP Version 5.2.5). The bug is already tracked and probably will be fixed in the next version of WordPress…
There are two solutions to fix this by your own
- Solution – Edit class-wp-filesystem-direct.php
Add the marked lines in your wp-admin/includes/class-wp-filesystem-direct.php (Line 281):
function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { // safe mode fails with a trailing slash under certain PHP versions. $path = untrailingslashit($path); if ( empty($path) ) $path = '/'; if ( ! $chmod ) $chmod = FS_CHMOD_DIR;
- Solution – Turn safe_mode off
I do not recommend this solution! But you can use it e.g. temporarily if you want to install a few plugins in a row and turn safe_mode on again afterwards. If you are using Confixx you can edit these settings easily. Otherwise you have to edit your php.ini manually. How to do this? Check that: Customizing PHP Safe Mode
OR
Now your Plugin installation process should give a response like this:
Downloading install package from http://downloads.wordpress.org/plugin/sample-plugin.zip
Unpacking the package.
Installing the plugin.
Successfully installed the plugin Sample Plugin.
If you still have problems with the installation of a wordpress plugin, read this.
Did this work for you? Tell me!
Incoming search terms:
19 Comments for this entry
1 Trackback or Pingback for this entry
-
Plugin upgrade Failed. Could not create directory. – Uwe
May 2nd, 2010 on 4:48 pm[...] ACP heraus oder fürs Core-Update. Untragbar dieser Zustand. Mögliche Problemlösung [via], die mir bestens geholfen hat, [...]
February 22nd, 2010 on 12:25 pm
Hey – your code changed my error from
“…
could not create directory. /var/www/html/web999/blog/wpcontent/plugins/sample-plugin/
Plugin Install Failed.”
to
“…
Incompatible Archive
Theme Install Failed.”
However. I tracked down this post at WordPress Multiuser from a week ago: http://mu.wordpress.org/forums/topic/16777 that has isolated my problem to a function call in /wp-admin/includes/class-wp-filesystem-ftpext.php.
He provides this one line edit: change the line
“$list = @ftp_rawlist($this->link, ‘-a ‘ . $path, false);”
to
“$list = ftp_rawlist($this->link, $path, false);”
It fixed my problem! Thanks for your help! This was driving me effing crazy.
March 15th, 2010 on 8:36 am
I tried your solution 1.
I pasted the code into the class-wp-filesystem-direct.php file.
Rebooted my system, went through install plugin but now get:
Parse error: syntax error, unexpected ‘;’, expecting T_FUNCTION in /var/www/wp/wp-admin/includes/class-wp-filesystem-direct.php on line 374
the file only goes up to 371…. any ideas?
April 29th, 2010 on 5:59 am
I had the same problem Peter.
In the original class-wp-filesystem-direct.php file (before you modified it) search for
function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
Then, directly underneath that line put
// safe mode fails with a trailing slash under certain PHP versions.
$path = untrailingslashit($path);
if ( empty($path) )
$path = ‘/’;
That worked for me
June 3rd, 2010 on 8:25 pm
Downloading update from http://downloads.wordpress.org/plugin/akismet.2.2.9.zip…
Unpacking the update…
Could not create directory. /
Actions: Return to Plugins page
I’m trying with a new and clean install of WP3 RC1.
June 14th, 2010 on 10:52 pm
Hey “illimar” I’m trying a clean install of wp3 rc1 and getting a similar error on a godaddy IIS7 server. Error “Could not create directory. D:/Hosting”, any luck yet?
I’ve modified the above files (if needed) and to no avail.
Would love a fix!
July 6th, 2010 on 8:32 am
I had the same problem in wp 3.0 but it was my fault, I have in my own server and i just needed to do this in the folder of my wordpress:
chown -R apache:apache *
or
chown -R www-data:www-data *
apache:apache user of apache server:group of apache server
I hope it can help to other users.
July 29th, 2010 on 12:48 am
oposiciones is correct! if you are using your own apache server you need to grant ownership of the files in your wordpress folder to your FTP user. THANKS!
You shouldn’t have to do this on a hosted solution such as godaddy, etc.
August 10th, 2010 on 3:31 pm
Hey oposiciones, that’s what got me going after horsing around with this problem for a while. I wonder if there’s some log or other facility that would provide some information to speed-up the process of deciphering the fact that it’s a permissions or ownership issue?
September 27th, 2010 on 11:46 am
I was having some issues with a host where the only way I could upload images from within WP was to have the uploads folder CHMOD to 777 which is not safe. Even more annoying, plugins were going to the uploads folder no matter how I set paths. I found an awesome plugin, WP Easy Uploader. Once this is installed, you can keep your folders locked down,not have to monkey with permissions or paths, and best of all, no longer have upload failures. I hope this helps someone.
http://wordpress.org/extend/plugins/wp-easy-uploader/
March 1st, 2011 on 10:28 am
I looked at this file and the lines you mention are already included.
Still I get this error and it started to occur after I installed a wordpress multisite in the root. The admin panel etc.. is up but I cant install any theme or plugin.
Before that I the latest version at its own db working just fine.
Now both of them give the error. I tried it on other domains and getting the same.
March 4th, 2011 on 9:50 pm
I was getting this error when trying to do a full WordPress upgrade (via the dashboard).
None of the above worked for me in making that error message go away, but I discovered it worked great once I manually deleted the wp-content/upgrade directory.
Previously my ftp user had had full rwx access to this directory. I’m guessing it was left behind (with nothing in it) by a previous upgrade, and for whatever reason the mkdir logic wasn’t smart enough to notice the directory already existed. That’s just my guess, however.
April 10th, 2011 on 12:45 pm
I had similar problems. After scratching my head and trying so many solutions. I remembered I had installed askapache plugin which password protects certain directories.
Soultion: Deactivate it > upgrade > Reactivate.
It worked for me…
April 12th, 2011 on 2:55 am
Excellent, Joe! Deactivating AskApache worked for me.
May 11th, 2011 on 6:37 pm
Could not create directory. /home/luthfi/public_html/staractoractress.com/wp-content/upgrade/google-analytics-for-wordpress.tmp/google-analytics-for-wordpress
how do I fix??
August 5th, 2011 on 7:16 pm
Perhaps it works, open your PHPmyAdmin,
Search in database: “path”
Browse .. match(es) inside table wp_options
Edit value : upload_url_path
August 16th, 2011 on 5:27 pm
I had this problem but it was all due to wordpress being installed on a local machine. In this case a Mac running Mamp. The fix was to run this command in terminal to chown -R _www:staff wordpress
replacing wordpress with the location of wordpress installation
January 3rd, 2012 on 4:07 pm
I fix this issue by configuring the local ftp server write permitions
May 16th, 2012 on 1:22 pm
Deactivating AskApache worked for me! Thanks
December 28th, 2012 on 5:57 am
it works like a wonder … hey thank you a ton
!!..
AskApache deactivated