WordPress 3.8: unable to locate wordpress content directory (wp-content)

21,845

Solution 1

Adding this line to my wp-config.php worked.

define('FS_METHOD', 'direct');

I have a local development environment on an Ubuntu server.

Solution 2

Try adding this line into your wp-config.php, it works for me

define('FS_METHOD', 'ftpsockets');
define('FTP_BASE', 'xxx');

Replace the xxx with your ftp home path e.g /opt/htdocs/wordpress

Solution 3

Try this one:)

//* FTP Settings **/
/** wp-content path */
define('FS_METHOD', 'ftpext');
define('FTP_BASE', '/');
define('FTP_CONTENT_DIR', '/wp-content/');
define('FTP_PLUGIN_DIR', '/wp-content/plugins/');
define('FTP_USER', 'testdomain4.com');
define('FTP_PASS', 'XXXXXXXXXXXX');
define('FTP_HOST', 'ftp.enterpriseit.us');
define('FTP_SSL', false);

see http://codex.wordpress.org/Editing_wp-config.php

Share:
21,845
Gabe Spradlin
Author by

Gabe Spradlin

Updated on August 06, 2020

Comments

  • Gabe Spradlin
    Gabe Spradlin almost 4 years

    I had my server setup just fine to allow me to update plugins, themes, and the core via the nice buttons WordPress provides. However, after upgrading to 3.8 I have not been able to upgrade anything. However, I also added iptables to the server around the same time but I don't think this is the issue - I shut off iptables and tried but didn't have any success.

    When I attempt to upload the plugin/update via WordPress's FTP it can't connect via localhost. Both 127.0.0.1 and the public IP return the "unable to locate wordpress content directory (wp-content)" after a long, long time suggesting a timeout or several timeouts.

    Environment:

    • WP 3.8 (multisite, subdirectory)
    • Ubuntu 12.04 server
    • vsftpd (so I can FTP my user)
    • Way back when (when I didn't know what I was doing) I changed the whole /var/www/ directory permissions to gabe:gabe. I have since tried changing the wp-content dir to gabe:www-data and www-data:www-data without success. I have also tried using chmod 777 on wp-content, again without success.

    I have googled and the vast majority of the fixes come down to permissions. However, as I stated above I've tried changing the owner and the permissions to 777 for the directory. So, I think permissions is a dead end.

    I originally thought iptables was somehow getting in the way. But I've shut it off/flushed the table without success. So I don't think iptables is the culprit.

    The other googled solutions amounted to adding some code to the wp-config.php file. However, one of those broke the site entirely. Another had no effect.

    The logs for Apache and the domain show nothing. They aren't empty but there isn't a single reference to wp-content or anything I can think of that would be related. The ftp logs show that a connection was successfully established via 127.0.0.1.

    So I've used up my bag of tricks at this point.

    ------------- Edit: Alterations I made to wp-config ------------- Per http://wordpress.org/support/topic/unable-to-locate-wordpress-content-directory-wp-content I changed the wp-config.php to include:

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

    This was a solution presented for the same problem back in WordPress 2.8 some 4 yrs ago. The site wouldn't load after adding these lines and given the age of the post/solution I took them out and did no further troubleshooting on why the site wouldn't load. I assumed it was calling some function that wasn't present in WP any longer.

    The second piece of code I added to wp-config.php was:

    putenv('TMPDIR='. ABSPATH .'tmp');
    define('WP_TEMP_DIR', ABSPATH . 'tmp');
    

    Per http://wordpress.org/support/topic/unable-to-locate-wordpress-content-directory-wp-content?replies=15. This didn't break the site but didn't fix it either so I removed it.

  • Gabe Spradlin
    Gabe Spradlin over 9 years
    Thanks for the reply, however, the site has since been upgraded and moved to a new server. The issue isn't an issue anymore and I don't have it to test solutions on anymore either.
  • NicolasZ
    NicolasZ almost 8 years
    In my case, in adition to add this line and delete the original one in the file [define('FS_METHOD', 'ftpext');], afterwards i had to change the permissions for WP-Content folder with "chmod -R 777 wp-content/"
  • Zoom Nguyễn
    Zoom Nguyễn about 6 years
    Thanks, you saved my life :)
  • mustafa
    mustafa over 4 years
    @NicolasZ 777 is an extremely dangerous setting. you can find a better solution