Archives

Most used wp-cli commands

Probably the most used wp-cli commands are the core, plugin, theme. We will discuss a little each one of them. Before running any wp-cli commands be sure to switch to the right directory:
cd /home/wp_directory

1. wp core – it installs, updates and manages a WordPress installation.
– to download the installation package
wp core download --locale=en_US

– to create the wp-config.php file needed for the installation process
wp config create --dbname=database_name --dbuser=wp_username --dbpass=wp_password

– to install WordPress
wp core install --url=domain.com --title=Example --admin_user=supervisor --admin_password=strongpassword --admin_email=name@domain.com

– to check if an update is available:
wp core check-update

-to update to the latest version:
wp core update

2. wp plugin – manages plugins
– to activate a plugin
wp plugin activate plugin-name

– to deactivate a plugin
wp plugin deactivate plugin-name

– to delete a plugin
wp plugin delete plugin-name

– to install and activate a plugin
wp plugin install plugin-name --activate

– to list all plugins
wp plugin list

– to update all plugins
wp plugin update --all

3. wp theme – manages themes
– to install the latest version of a theme and activate it
wp theme install twentynineteen --activate

– to activate a theme already installed
wp theme activate twentynineteen

– to get a list of the installed themes
wp theme list

– to update all the themes installed
wp theme update --all

Related articles:
How to install wp-cli on your server

References:
WP-CLI Commands

Share this post:

How to install wp-cli on your server

WP-CLI is a command-line interface for WordPress.  Through it, you can manage your installations from the command line.

Official requirements you should check prior to installing WP-CLI:

– UNIX-like environment (OS X, Linux, FreeBSD, Cygwin); limited support in Windows environment
– PHP 5.4 or later
– WordPress 3.7 or later. Versions older than the latest WordPress release may have degraded functionality

The first thing we must do is to download the wp-cli phar file. As root, use the command:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

root@web [/]# curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5294k 100 5294k 0 0 8635k 0 --:--:-- --:--:-- --:--:-- 8637k
root@web [/]#

Now, let’s check the phar file is in good condition and to get some info about the wp-cli. Use:
php wp-cli.phar --info

root@web [/]# php wp-cli.phar --info
OS: Linux 2.6.32-042stab134.3 #1 SMP Sun Oct 14 12:26:01 MSK 2018 x86_64
Shell: /bin/bash
PHP binary: /opt/cpanel/ea-php73/root/usr/bin/php
PHP version: 7.3.4
php.ini used: /opt/cpanel/ea-php73/root/etc/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.1.0
root@web [/]#

We want to use the wp-cli tool with the “wp” command so let’s run the commands:
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

The first command makes the file executable, the second one moves it to /usr/loca/bin/wp folder.

Everything is done now, let’s test it. Use:
wp --info

root@web [/]# wp --info
OS: Linux 2.6.32-042stab134.3 #1 SMP Sun Oct 14 12:26:01 MSK 2018 x86_64
Shell: /bin/bash
PHP binary: /opt/cpanel/ea-php73/root/usr/bin/php
PHP version: 7.3.4
php.ini used: /opt/cpanel/ea-php73/root/etc/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.1.0
root@web [/]#

If you are running cPanel on the server, the wp-cli tool is already installed in /usr/local/cpanel/3rdparty/bin/wp. Many times, 3rd party apps are not updated frequently, so you may want to install wp-cli manually, as described above.

 

To update the wp-cli tool, use:
wp cli update

root@web [/]# wp cli update
Success: WP-CLI is at the latest version.
root@web [/]#

Thank you.

Related articles:
Most used wp-cli commands

Resources:
https://wp-cli.org/
https://wp-cli.org/#installing

Share this post:

WordPress Automatic Updates

Many users are asking us how to enable automatic updates in WordPress. For the moment, there is no option in the WordPress admin panel. You must enable this option by editing the configuration file – wp-config.php.

wordpress autoupdate

The line that needs to be added to the bottom of the wp-config.php file to enable automatic minor and major updates is:

define( 'WP_AUTO_UPDATE_CORE', true );

More info on the WP_AUTO_UPDATE_CORE option from the WordPress site:

WP_AUTO_UPDATE_CORE can be defined with one of three values, each producing a different behavior:

Value of true – Development, minor, and major updates are all enabled
Value of false – Development, minor, and major updates are all disabled
Value of ‘minor’ – Minor updates are enabled, development, and major updates are disabled

Notice: The WordPress will update itself to a development release ONLY if you already are using such a release.

The video tutorial for this article:

References:
https://codex.wordpress.org/Configuring_Automatic_Background_Updates

Share this post:

Install WordPress on a user account as root

You don’t have Softaculous on your server and a user asks you to install WordPress for him.
You can download the WordPress zip, unzip the archive, upload the files via FTP to the user account. You will also need to log in to cPanel and create the database and username.

We will show you an alternative way to install WordPress. We will install WordPress for user “plothost”.

  1. Login as root via SSH on your web hosting server.
  2. Change location to where you want to install WordPress
    root@web [~]# cd /home/plothost/public_html/
    root@web [/home/plothost/public_html]#
    
  3. Download the latest WordPress version. The permanent link is https://wordpress.org/latest.zip
    root@web [/home/plothost/public_html]# wget https://wordpress.org/latest.zip
    --2017-05-01 08:14:59--  https://wordpress.org/latest.zip
    Resolving wordpress.org (wordpress.org)... 66.155.40.249, 66.155.40.250
    Connecting to wordpress.org (wordpress.org)|66.155.40.249|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 8756989 (8.4M) [application/zip]
    Saving to: 'latest.zip'
    
    100%[==============================================================================================================================>] 8,756,989   7.07MB/s   in 1.2s
    
    2017-05-01 08:15:01 (7.07 MB/s) - 'latest.zip' saved [8756989/8756989]
    
    root@web [/home/plothost/public_html]#
    
    
  4.  Extract the archive-zip file in the current directory.
    root@web [/home/plothost/public_html]# unzip latest.zip -d .
    

    The zip archive will be extracted to public_html/plothost/wordpress/

  5. We want to install WordPress in public_html/ folder. So let’s move the files.
    root@web [/home/plothost/public_html]# mv ./wordpress/* .
    

    We now have all the WordPress files in /plothost/public_html/

  6. We should create the database and assign the username
    root@web [/home/plothost/public_html]# mysql
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 384766
    Server version: 10.1.22-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> CREATE DATABASE wpbase;
    Query OK, 1 row affected (0.00 sec)
    
    MariaDB [(none)]> CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'pass123456';
    Query OK, 0 rows affected (0.19 sec)
    
    MariaDB [(none)]> GRANT ALL ON wpbase.* TO 'wpuser'@'localhost';
    Query OK, 0 rows affected (0.02 sec)
    
    MariaDB [(none)]>
    
  7. We rename the configuration file wp-config-sample.php to wp-config.php
    root@web [/home/plothost/public_html]# mv wp-config-sample.php wp-config.php
    root@web [/home/plothost/public_html]#
    
  8. Edit the file wp-config.php in your preferred editor (like vi). Modify the lines with the WordPress details you’ve used earlier:

    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘database_name_here’);

    /** MySQL database username */
    define(‘DB_USER’, ‘username_here’);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘password_here’);

    becomes

    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘wpbase’);

    /** MySQL database username */
    define(‘DB_USER’, ‘wpuser’);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘pass123456’);

  9. We are almost finished. Let’s change the files’ user/group, so the user can modify the files.
    root@web [/home/plothost/public_html]# chown -R plothost:plothost .
    
  10. You can now give the installation URL to the user, and he/she will finish the installation by entering Site Title, Admin Username and Password, Email. (as in the image below)

WordPress Install Options

On our web hosting plans you can install WordPress easily via Softaculous. Check out the WordPress Hosting page.

Share this post:

Add AMP HTML support to your WordPress blog

Accelerated Mobile Pages (AMP) is an HTML type language that is optimized for mobile using. Google puts more and more SEO value on AMP pages. For example, you can see statistics for your AMP pages in Google Analytics. In this post we will show you how to install the AMP WordPress plugin by Automattic.

The steps to support AMP in WordPress:

  1. Log in to your WordPress installation (usually the url is domain.com/wordpress_directory/wp-login.php)
  2. Go to Plugins->Add New
  3. Type “AMP” in the Search plugins edit box
  4. You’ll see a list of available plugins. Install the AMP by Automattic plugin by clicking the Install button. 
  5. Activate the plugin by clicking the Activate button.
  6. Now you will have AMP support for your WordPress blog. To see the AMP pages, just add /amp/ to any URL on your blog.(eg. domain.com/post-1/amp/)

Here is a short video tutorial:

You can verify your /amp/ posts with the official HTML AMP Validator https://validator.ampproject.org/

To customize the look of the AMP pages, you can install the AMP for WP – Accelerated Mobile Pages (it requires the AMP plugin by Automattic)

WordPress AMP Plugins
WordPress AMP Plugins

For other AMP related plugins, search the WordPress site https://wordpress.org/plugins/search/amp/

Related KB post: How to convert HTML to AMP

Share this post:
Page 1 of 2
1 2