Wordpress: Could not create directory – Theme Install Failed

by admin on Feb.10, 2010, under Wordpress

This error appeared every time I wanted to install a theme automatically, even in the current version (2.9.1) of Wordpress:

Downloading install package from http://wordpress.org/extend/themes/download/sample-theme.zip.
Unpacking the package.
Installing the theme.
Could not create directory. /var/www/html/web999/blog/wp-content/themes/sample-theme/
Theme 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

  1. 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;
  2. OR

  3. 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 themes 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

Now your Theme installation process should give you a response like this:

Downloading install package from http://wordpress.org/extend/themes/download/theme.zip.
Unpacking the package.
Installing the theme.
Successfully installed the theme Sample Theme.

Did this work for you? Tell me!

  • Share/Bookmark

Related posts:

  1. Wordpress: Could not create directory – Plugin Install Failed
:, , , , , ,

3 Comments for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...