6

As a highly concerned hosting company owner I am using WP-CLI to update plugins, themes and wp core of my clients.

Updating WP-Core

find /home/*/public_html -name "wp-admin" -execdir /home/wp core update --allow-root \;

Updating Plugins

find /home/*/public_html -name "wp-admin" -execdir /home/wp plugin update-all --allow-root \;

Updating Themes

find /home/*/public_html -name "wp-admin" -execdir /home/wp theme update-all --allow-root \;

Everything is working extremely well, but I want just to change CACHE folder for WP-CLI since I do not want it to store in /root/wp-cli/.cache

It's actually not storing anything there because I enabled Open base dir, how can I change location of cache folder for wp cli? is there a syntax? I can't find any docs on it

PHP Warning:  file_exists(): open_basedir restriction in effect. File(/root/.wp-cli/cache/) is not within the allowed path(s): (/home:/tmp:/opt/cpanel/composer/bin/composer) in phar:///home/wp/php/WP_CLI/FileCache.php on line 261

I honestly do not know what is cache folder used for but since wp cli can't use it I am just afraid that something will fail, but so far it didn't.

  • don't remember the exact configuration file but IIRC there are different php.ini loaded for command line and web server "cgi". you should probably add the "open_basedir" setting only in the web server related one – Mark Kaplun May 21 '17 at 16:16
  • That wasn't what I asked. I simply asked how to set different cache directory – Luka May 21 '17 at 16:37
  • OMG yet another millennial that have to get his food exactly how he ordered it, god forbid someone adds anything new. If after all the time you have been around stackexchange and haven't learned yet that answers and comments are not directed especially to the OP, maybe it is time to start understanding that. Not something useful for you? you can just ignore. Want things tailored to your needs? pay someone. – Mark Kaplun May 21 '17 at 16:53
  • You are suggesting me to disable open_basedir so my clients can sniff around if they use ssh, great ideaa i accept it lets roll the dice. – Luka May 21 '17 at 17:04
5

You could try to change it through the environment variable:

WP_CLI_CACHE_DIR

as we have it included in the WP_CLI::get_cache() method (src):

$dir = getenv( 'WP_CLI_CACHE_DIR' ) ? : "$home/.wp-cli/cache";

You can also check out issue #1848 - Use shared cache directory for multiple installs for usage examples.

In the WP-CLI Handbook on make.wordpress.org, we have a list of environment variables used by WP-CLI.

0

This is actually how I ended up doing this, this is a script I wrote for updating themes, plugins and wp core on cPanel servers

#!/bin/bash

rm -rf /home/wp
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /home/wp
chmod +x /home/wp
sleep 5

Red='\033[0;31m'
Color_Off='\033[0m'

echo -e "$Red Updating WP core $Color_Off";

for i in `ls /var/cpanel/users/`; do sudo -H -u $i cp /home/wp /home/$i/wp && sudo -H -u $i find /home/$i/public_html -name 'wp-admin' -execdir /usr/local/bin/php /home/$i/wp core update \; && sudo -H -u $i rm -rf /home/$i/wp ; done

echo -e "$Red Updating plugins $Color_Off";

for i in `ls /var/cpanel/users/`; do sudo -H -u $i cp /home/wp /home/$i/wp && sudo -H -u $i find /home/$i/public_html -name 'wp-admin' -execdir /usr/local/bin/php /home/$i/wp plugin update-all \; && sudo -H -u $i rm -rf /home/$i/wp ; done

echo "$Red Updating themes $Color_Off";

for i in `ls /var/cpanel/users/`; do sudo -H -u $i cp /home/wp /home/$i/wp && sudo -H -u $i find /home/$i/public_html -name 'wp-admin' -execdir /usr/local/bin/php /home/$i/wp theme update-all \; && sudo -H -u $i rm -rf /home/$i/wp ; done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.