Join the community today
Register Now

Featured Wordpress Quick How to update Wordpress via SSH with WP-CLI

Discussion in 'Blogs & CMS usage' started by eva2000, Feb 23, 2015.

  1. eva2000

    eva2000 Administrator Staff Member

    28,942
    6,570
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,751
    Local Time:
    9:06 AM
    Nginx 1.13.x
    MariaDB 5.5
    For wp-cli Centmin Mod Addon users a quick guide to updating wordpress from SSH command line :)

    Go to server /root to update wp-cli command if you already installed it via wp-cli Centmin Mod addon, and update wp-cli to latest version

    Code:
    cd /root
    wp cli info --allow-root; curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar; chmod +x wp-cli.phar; echo yes | mv wp-cli.phar /usr/bin/wp; wp cli info --allow-root
    
    then change into your wordpress install directory i.e. /home/nginx/domains/wordpressite.com/wp

    Code:
    cd /home/nginx/domains/wordpressite.com/wp
    
    then check current version of Wordpress

    Code:
    wp core version --allow-root
    4.1
    
    then check if there is an update to the Wordpress core which here shows a minor 4.1.1 update is available

    Code:
    wp core check-update --allow-root
    +---------+-------------+-------------------------------------------+
    | version | update_type | package_url                               |
    +---------+-------------+-------------------------------------------+
    | 4.1.1   | minor       | https://wordpress.org/wordpress-4.1.1.zip |
    +---------+-------------+-------------------------------------------+
    
    then update Wordpress core

    Code:
    wp core update --allow-root
    Updating to version 4.1.1 (en_US)...
    Downloading update from https://downloads.wordpress.org/release/wordpress-4.1.1-no-content.zip...
    Unpacking the update...
    Success: WordPress updated successfully.
    
    then update Wordpress database

    Code:
    wp core update-db --allow-root
    Success: WordPress database upgraded successfully.
    
    re-run core update a 2nd time as per wp-cli docs

    Code:
    wp core update --allow-root
    
    Check version of Wordpress you are now on for your site

    Code:
    wp core version --allow-root
    4.1.1
    All done updating Wordpress via SSH command line using WP-CLI :D

    For other commands on updating plugins and themes check out Built-in Commands | WP-CLI. Wordpress Plugin updates via SSH command line with WP-CLI can also be done wp plugin | WP-CLI

    List all plugins and update all plugins

    Code:
    cd /home/nginx/domains/wordpressite.com/wp
    
    wp plugin list --allow-root
    wp plugin update --all --allow-root
    
    Or update individual Wordpress plugin i.e. Akismet

    Code:
    cd /home/nginx/domains/wordpressite.com/wp
    
    wp plugin update akismet --allow-root
    Enabling Maintenance mode...
    Downloading update from https://downloads.wordpress.org/plugin/akismet.3.0.4.zip...
    Unpacking the update...
    Installing the latest version...
    Removing the old version of the plugin...
    Plugin updated successfully.
    Disabling Maintenance mode...
    Success: Updated 1/1 plugins.
    If you wanted all the commands to run they would be as follows where WPURL= variable needs changing to your full path to your wordpress install directory


    Code:
    WPURL=/home/nginx/domains/wordpressite.com/wp
    
    cd /root
    wp cli info --allow-root; curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar; chmod +x wp-cli.phar; echo yes | mv wp-cli.phar /usr/bin/wp; wp cli info --allow-root
    
    cd $WPURL
    
    wp core version --allow-root
    
    wp core check-update --allow-root
    
    wp core update --allow-root
    
    wp core update-db --allow-root
    
    wp core update --allow-root
    
    wp core version --allow-root
    
    wp plugin list --allow-root
    
    wp plugin update --all --allow-root
    
     
    Last edited: Jul 26, 2016
    • Like Like x 1