Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 744
Gabe Spradlin Avatar asked Feb 22 '14 21:02

Gabe Spradlin


2 Answers

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

define('FS_METHOD', 'direct');

I have a local development environment on an Ubuntu server.

like image 180
jon_childs Avatar answered Sep 30 '22 22:09

jon_childs


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

like image 39
marklaiky Avatar answered Sep 30 '22 23:09

marklaiky