Get 25 USD Free To USE VPSSIM

Huớng dẫn cài đặt WP-CLI để quản lý wordpress blog trên SSH

Posted on: 03/11/2017 Last Updated: 03/11/2017 No comments

WP-CLI là một tiện tích dùng để quản lý wordpress log trên SHH qua command.  Chúng ta có thể làm đuợc rất  nhiều việc mà không cần phải login vào wordpress admin nữa. Bạn có thể update plugins, themes, cài đặt wordpress multisite, sao lưu, phục hồi database, cài đặt wordpress mới …

cach cai dat va huong dan su dung wp cli de quan li wordpress - Huớng dẫn cài đặt WP-CLI để quản lý wordpress blog trên SSH

Lệnh cài đặt WP-CLI

Dơwnload phar file:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Kiểm tra file phar file

 php wp-cli.phar --info

Rồi cài:

chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp

Lệnh update WP-CLI

wp cli update

Kiểm tra cài đặt

Dùng lệnh dưới để kiểm tra:

wp --info

Kết quả:

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

Một số lệnh thường dùng

Trước khi chạy wp-cli, bạn cần cd tới thư mục root của domain.

cd /home/vpssim.vn/public_html

Nếu bạn chạy wp-cli bằng user root, bạn phải thêm –allow-root vào cuối lệnh của mình thì wp-cli mới chạy đựợc nhé.

ví dụ:

wp plugin status --allow-root

Lệnh thường dùng:

Trước tiên, mình ví dụ một cách cài wordpress bằng wp-cli rất nhanh nhé.

cd /home/vpssim.vn/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/vpssim.vn/public_html/
wp core config --dbname=dataname --dbuser=username --dbpass=password --allow-root
wp core install --url="https://vpssim.vn" --title="Tenwebsite" --admin_user="tenadmin" --admin_password="matkhauadmin" --admin_email="admin@oanh.win" --allow-root

Như vậy là dơwnload và cài đặt xong một blog mới. Rất nhanh đúng không ?

Check plugin status:

wp plugin status

Update tất cả plugins:

wp plugin update --all

Tìm một plugin:

wp plugin search bulletproof

Cài đặt Plugin:

wp plugin install bulletproof-security

Acctivated một plugin:

wp plugin activate bulletproof-security

Vừa cài đặt, vừa activate ta sẽ dùng lệnh:

wp plugin install bulletproof-security --activate

Check themes status:

wp theme status

Cài đặt và kích họat theme:

wp theme install ten_theme --activate

Nâng cấp wordpress code:

wp core update

Cập nhật database sau khi nâng cấp code:

wp core update-db

Sao lưu database:

wp db export > ten_file.sql

Create User:

wp user create bob bob@example.com --role=author

Còn rất nhiều lệnh khác nữa, các bạn tìm hiểu thêm tại đây nhé.

Chúc các bạn thành công.

Bài Viết Liên Quan:


Tạm thời mình đóng comment, bạn vui lòng sử dụng diễn đàn để được trả lời nhanh nhất.
Diễn đàn: https://community.vpssim.vn

Không bỏ lỡ tin tức, bài viết mới trên
HostingAZ.VN