WP-CLI error installing plugins/themes. "Could not create directory". Permissions error? Ubuntu 14.04 x64 WP-CLI error installing plugins/themes. "Could not create directory". Permissions error? Ubuntu 14.04 x64 wordpress wordpress

WP-CLI error installing plugins/themes. "Could not create directory". Permissions error? Ubuntu 14.04 x64


I found an answer here to make it work on my local MBP OSX Server. Add define('FS_METHOD','direct'); to wp-config.php.

Make sure all files and folders are 775 (did not reduce the permissions yet but I am positive less is workable - i.e. 664 for files - locally too) and all files and folders are owned by your user and group _www.Inside the project folder run:

sudo chown user:_www  *sudo chmod -R 775 *

This should allow you to run wpcli and create directories without issues and without using root.

NB _www is for OSX Apache user group. For Ubuntu you need www-data

NBB Running Mod PHP here, with (Fast) CGI (Shared) Hosting setup 755 for directories and 644 for files normally works well.


Maybe you have to define in your config.php file where is located the content directory. Depending on configuration of your server, try adding one of this two line of code:

define('WP_CONTENT_DIR', realpath(dirname(__FILE__) . '/content'));

or

define('WP_CONTENT_DIR', realpath($_SERVER['DOCUMENT_ROOT'] . '/content'));

Try with the first, if it doesn't work try with the second. I've found the same error configuring wp-deploy and this worked for me.


For me, all I had to do was sudo chmod -R 775 wp-content. The owner did not affect the plugin update for me and I did not have to make any other changes.

Regarding what @helgatheviking was saying about "hardening"... If you're worried about security and want to be secure as possible change it back to 755 afterwards! I'd say that this is a good thing to do as long as you don't mind changing the permissions with every WP-CLI plugin update.