Guide to install WP-CLI to manage wordpress blog on SSH?

Philippe Gaucher

Well-known member
Collaborate
Registered
Joined
Jul 27, 2016
Messages
184
Points
18
Can you guys guide me to install WP-CLI to manage my wordpress blog on SSH? I heard that using WP-CLI will make my work with WordPress easier and faster, is that true?
 

David Beroff

Well-known member
Registered
Joined
Jun 14, 2016
Messages
1,477
Points
63
WP-CLI is a handy tool for managing wordpress blogs on SHH via command line. We can do a lot of work without login to the wordpress admin anymore. You can update plugins, themes, install wordpress multisite, backup, restore database, install new Wordpress...etc

Command to install WP-CLI

Download phar file:

Code:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Check out the phar file

Code:
 php wp-cli.phar --info
Then install:

Code:
chmod + x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
Command to update WP-CLI

Code:
wp cli update
Check settings

Use the following command to check:
Code:
wp --info
Result:

Code:
PHP binary:/usr/bin/php
PHP version:5.6.32
php.ini used:/etc/php.ini
WP-CLI root dir:phar://wp-cli.phar
WP-CLI vendor dir:phar://wp-cli.phar/vendor
WP_CLI phar path:/root
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version:1.4.0
Some commands are often used. Before running wp-cli, you need to cd to the root directory of your domain.

Code:
cd /home/example.com/public_html
If you run wp-cli with root user, you must add -allow-root to the end of your command, then run wp-cli offline.

For example:

Code:
wp plugin status --allow-root
First, my example is a way to install wordpress with wp-cli quickly.
Code:
cd /home/example.com/public_html
wget https://wordpress.org/latest.zip
unzip -q latest.zip
mv wordpress / * ./
rm -rf wordpress
rm -rf latest.zip
chown -R nginx:nginx /home/example.com/public_html/
wp core config --dbname = dataname --dbuser = username --dbpass = password --allow-root
wp core install --url = "http://example.com" --title = "website_name" --admin_user = "admin" --admin_password = "password" --admin_email = "[email protected]" allow-root
This way above is to download and install a new blog. Very fast, right?

Check plugin status:

Code:
wp plugin status
Update all plugins:

Code:
wp plugin update --all
Find a plugin:

Code:
wp plugin bulletproof search
Plug-in installation:

Code:
wp plugin install bulletproof-security
Acctivated a plugin:

Code:
wp plugin activate bulletproof-security
Once installed, just activate with command:

Code:
wp plugin install bulletproof-security --activate
Check themes status:

Code:
wp theme status
Install and activate the theme:

Code:
wp theme install theme_name --activate
Upgrade wordpress code:

Code:
wp core update
Update database after upgrade code:

Code:
wp core update-db
Database backup:

Code:
wp db export> file_name.sql
Create User:

Code:
wp user create yourname [email protected] --role=author
Hope it helps!
 
Last edited:
Older Threads
Replies
13
Views
5,121
Replies
3
Views
1,825
Replies
6
Views
4,436
Replies
3
Views
1,841
Replies
0
Views
1,312
Newer Threads
Replies
12
Views
3,932
Replies
2
Views
1,138
Replies
2
Views
1,923
Recommended Threads
Replies
6
Views
12,296
Replies
0
Views
1,256
Replies
33
Views
11,953
Replies
8
Views
4,341
Similar Threads
Replies
0
Views
923
Replies
3
Views
2,925
Replies
9
Views
3,091

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top