WP-CLIPHAR 로 작성된 유틸리티로 command 로  wordpress 를 관리할 수 있는 유틸리티이다.

플러그인 관리, 워드프레스 업그레이드등의 관리 작업을 커맨드로 실행할 수 있으므로 자동화된 관리가 가능하며 다수의 워드프레스 사이트를 손쉽게 운영할 수 있는 장점이 있다.

설치

wordpress command line 유틸리티인 wp-cli 설치하기 참고

설정

wp-cli 는 설정 파일로 동작을 제어할 수 있다. 설정 파일인 yml 형식을 가지며 설정 파일을 처리하는 순서(우선 순위)는 다음과 같다. 숫자가 작을수록 우선 순위가 높다.


순서

  1. Command-line flags (Ex: --path)
  2. 현재 작업 디렉터리 또는 상위 디렉터리에 있는 wp-cli.local.yml 파일

    현재와 상위에 둘 다 wp-cli.local.yml 이 있으면 상위에 있는 설정 파일을 적용한다.

  3. 현재 작업 디렉터리 또는 상위 디렉터리에 있는 wp-cli.yml.
  4. 사용자의 홈 디렉터리 밑에 ~/.wp-cli/config.yml 파일. (WP_CLI_CONFIG_PATH 환경 변수를 지정하면 다른 위치로 지정할 수 있다.)
  5. Defaults


설정 파일 예

모든 항목은 앞에 대시 두 개를 붙이면 명령행 플래그로 사용 가능하다. 설정 파일에 지정된 path 는 wp-cli --path  명령행 플래그로 덮어 쓸 수 있다.

설정 파일 예

# Path to the WordPress files 
path: wp-core
## Pretend request came from given URL. In multisite, this argument is how the target site is specified. 
url: http://example.com
user: admin
color: auto
disabled_commands:
  - db drop
  - plugin install
require:
  - path-to/command.php

core config:
	dbuser: root
	dbpass: 
	extra-php: |
		define( 'WP_DEBUG', true );
		define( 'WP_POST_REVISIONS', 50 );
BASH
  • path
    워드프레스의 설치 경로 

  • url
    워드프레스 사이트 URL 

  • user : wordpress 관리자 id 를 설정한다.

  • color

  • disabled_commands

  • require

  • core config

    • dbuser 
    • dbpass
    • extra-php


core 명령어

워드프레스의 코어를 관리할 수 있는 명령어 집합.

version 확인

$ wp-cli core version
 
3.9.3
CODE


워드프레스 download 

워드프레스 최종 버전(en_US 버전)을 현재 디렉토리로 다운로드 한다.

$ wp-cli core download
CODE

워드프레스 업데이트

워드프레스의 가장 최근 릴리스 버전으로 업데이트 한다.

wp-cli core update
CODE

특정 버전으로 업데이트 하려면 version 옵션을 지정한다. 마지막은 URL 로 생략하면 wordpress.org (한글 버전일 경우 ko.wordpress.org)에서 다운로드 한다.

wp-cli core update --version=3.9.3 http://wordpress.org/wordpress-3.9.3.zip
CODE

정상적으로 업데이트 되었는지는 wp-cli  version 명령어로 확인할 수 있다.


verify-checksums

설치된 워드프레스의 체크섬을 WordPress.org’ 와 비교해서 결과를 출력한다. 위변조 여부 확인을 통해 워드프레스가 해킹 당했는지 판단할 때 유용한 명령어이다.

$ wp-cli core verify-checksums
 
Warning: File doesn't verify against checksum: wp-load.php
Error: WordPress install doesn't verify against checksums.
CODE

menu

메뉴 목록 보기

wp-cli menu list
CODE


config

wp-config.php 파일 관리 및 정보 보기. 자세한 옵션은 위 링크 참조


하며 dbname과 dbuser 는 필수 아규먼트

wp-config 생성

$ wp config create --dbname=db1 --dbuser=user1
CODE
$ wp config get
CODE

워드 프레스 설치

$ wp core install --admin_user=admin --admin_email=admin@gmail.com --url=http://mywp.example.com --title='테스트'
CODE



plugin

플러그인을 설치/삭제/갱신할 수 있다.

목록 보기

wp-cli plugin list 
CODE


상태 표시

wp-cli plugin status hello-dolly 
 
Plugin hello-dolly details:
    Name: Hello Dolly
    Status: Inactive
    Version: 1.5 (Update available)
    Author: Matt Mullenweg
    Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
CODE


설치

$stringEscapeUtils.escapeHtml($body)
BASH


삭제

## 
wp-cli plugin uninstall hello-dolly
CODE


활성/비활성

## 활성
wp-cli plugin activate hello-dolly
 
## 비활성
wp-cli plugin deactivate hello-dolly
BASH


업데이트

하나 이상의 플러그인을 업데이트 할 수 있으며 --all 옵션을 지정하면 모든 플러그인을 업데이트한다.

  • --version=<version> 설정됐으면 마지막 버전이 아닌 특정 버전으로 업데이트한다. <version> 을 dev 로 설정하면 개발중인 버전으로 업데이트한다.
  • [--dry-run]Preview which plugins would be updated.


wp-cli plugin update hello-dolly --version=1.6
CODE


사용자 관리

사용자 목록 보기

$ wp-cli user list
 
+---------+----------------+--------------+-----------------------------+---------------------+---------------+
| ID      | user_login     | display_name | user_email                  | user_registered     | roles         |
+---------+----------------+--------------+-----------------------------+---------------------+---------------+
| 1       | admin          | admin        | admin@example.com           | 2013-04-24 10:15:25 | administrator |
| 2       | user1          | user1        | user1@example.net           | 2013-08-05 14:31:01 | administrator |
CODE


사용자 암호 변경

ID 가 1번인 사용자의 암호를 mypass 로 변경

wp-cli user update 1 --user_pass=mypass
CODE


theme

wp-cli 로 wordpress 테마 관리하기 참고

같이 보기

Ref