Learn about Centmin Mod LEMP Stack today
Register Now

wpcli.sh addon discussion

Discussion in 'Add Ons' started by eva2000, Apr 10, 2015.

  1. eva2000

    eva2000 Administrator Staff Member

    54,600
    12,225
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,794
    Local Time:
    3:04 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Discussion thread for official Centmin Mod wpcli.sh Addon.

    Full working WP-CLI usage guide added here.

    Centmin Mod v1.2.3 beta adds support for Wordpress WP-CLI tool which allows you to manage Wordpress installations from command line - including updating plugins, multisite wordpress installs and creating post etc. The addon can be found in zip download folder /addons/wpcli.sh.

    You'll need to give wpcli.sh executable permissions before running the script.


    Note: If you're using older Centmin Mod version prior to using latest Centmin Mod v1.2.3 beta (13/06/13 dated), you will need to first run centmin.sh menu option #5 to recompile PHP so you have readline and PCNTL PHP extension support first before running wpcli.sh.
    Code:
    cd /usr/local/src/centmin-v1.2.3mod/addons/
    chmod +x wpcli.sh
    ./wpcli.sh install
    
    Then log out of SSH telnet session, then log back in so below commands work properly. This only has to be done the initial time after install only.

    WP-CLI requires installation of git on your CentOS server and the Centmin Mod Addon script installer will take care of all dependency requirements including the required PHP readline and PCNTL extension support.
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,600
    12,225
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,794
    Local Time:
    3:04 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    WP-CLI version 0.14 was released with changes to prevent the tool from being run as root user. When you run WP-CLI command as root user you will get the below warning and suggestions on 2 ways to now run the tool. For now with Centmin Mod, you would need to use --allow-root flag. At least until future Centmin Mod versions support proper chrooted and jailed individual user accounts (see preview of this feature here).

    Running command:
    Code:
    wp --info
    
    will now result in warning below
    Code:
    Error: YIKES! It looks like you're running this as root. You probably meant to run this as the user that your WordPress install exists under.
    
    If you REALLY mean to run this as root, we won't stop you, but just bear in mind that any code on this site will then have full control of your server, making it quite DANGEROUS.
    
    If you'd like to continue as root, please run this again, adding this flag: --allow-root
    
    If you'd like to run it as the user that this site is under, you can run the following to become the respective user:
    
    sudo -u USER -i -- wp ...
    
    To run command now with 0.14, you need to run as:
    Code:
    wp --info --allow-root
    
    output:
    Code:
    PHP binary: /usr/local/bin/php
    PHP version: 5.5.8
    php.ini used: /usr/local/lib/php.ini
    WP-CLI root dir: phar://wp-cli.phar
    WP-CLI global config:
    WP-CLI project config:
    WP-CLI version: 0.14.0
    
     
  3. deltahf

    deltahf Premium Member Premium Member

    587
    265
    63
    Jun 8, 2014
    Ratings:
    +489
    Local Time:
    12:04 AM
    After too many years I am finally using WP-CLI to manage my WordPress install and it's awesome. I didn't realize it was built into Centminmod and I'm really wishing I had done this sooner!

    One note: I could not get this to run as my site's (non-root) user and the sudo command mentioned above didn't work (it said my site's user account was in the sudoers file, and I didn't want to mess with that). To fix this I just updated the permissions on the /usr/bin/wp file from 700 to 755:

    Code (Text):
    $ chmod 755 /usr/bin/wp
    


    I would highly recommend everyone use WP-CLI if you are running WordPress!
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,600
    12,225
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,794
    Local Time:
    3:04 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yeah Centmin Mod has lots of goodies :D

    How was the sudo user created ? Centmin Mod has it's own tools/addsudousers.sh tool to that for Centmin Mod environments too https://community.centminmod.com/threads/best-practice-for-a-sudo-developer-user.15715/#post-67251

    You can add a new sudo user i.e. george via below commands
    Code (Text):
    cd /usr/local/src/centminmod/tools
    ./addsudousers.sh george