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!
Related posts:
8 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?