Update WordPress Unable to locate WordPress Root directory.Installation Failed

When you try to update WordPress you get the error:

Update WordPress

Unable to locate WordPress Root directory.

Installation Failed

This problem is solved by adding the following code to the wp-config file:

if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}

(source: http://wordpress.org/support/topic/autoupdate-unable-to-locate-wordpress-root-directory)

You will then get the error:

Downloading update from http://wordpress.org/wordpress-3.3.2-partial-1.zip…

Unpacking the update…

Could not create directory.: /home/nginx/domains/mysite.com/public/blog/wp-content/upgrade/wordpress-3.tmp

Installation Failed

This means that there is a permission problem.

First, check who is the ‘owner’ of the files with the command”

 ls -l

The output will be as follows:

 
root@all-sites:/var/www/mydomain/htdocs/wp-content# ls -l
total 36
-rw-r--r--  1 www-data www-data 1027 Oct 24  2017 advanced-cache.php
drwxr-x---  4 www-data www-data 4096 Nov 21 19:23 cache
-rw-r--r--  1 www-data www-data   28 Oct 24  2017 index.php
drwxr-xr-x  9 www-data www-data 4096 Nov 21 10:16 plugins
drwxr-xr-x 15 www-data www-data 4096 Nov 21 10:43 themes
drwxr-xr-x  2 www-data www-data 4096 Nov 21 10:43 upgrade
drwxr-x---  6 www-data www-data 4096 Jan  5  2018 uploads
-rw-r--r--  1 www-data www-data 4868 Oct 20 15:49 wp-cache-config.php
root@all-sites:/var/www/mydomain/htdocs/wp-content

This indicates that the owner is “www-data” and the group is “www-data”.

If it shows something else, change the owner and the group with this command:

 chown www-data:www-data -R * 

This will change everything on a recursive basis.

If you want to change only a file or a folder, use the command:

 chown www-data:www-data nameoffile.php 
 chown www-data:www-data -R nameoffolder 

If the server is running on nginx, the owner and group may be ‘nginx’.

In VirtualMin, the owner and group is given the name of the website.

Once, the owner issue is sorted out, the permission issue will be resolved.

3 thoughts on “Update WordPress Unable to locate WordPress Root directory.Installation Failed

Leave a Reply

Your email address will not be published. Required fields are marked *