5
9

More than 5 years have passed since last update.

WordPress Cli による環境構築

Last updated at Posted at 2016-09-16

Setup

Curl や Composerなど様々なインストール方法があるので下記参照

WordPress本体のインストール

まずはコアのダウンロード。現在のフォルダにWP基本ファイルを展開する。

$ wp core download --locale=ja

デフォルトは.にファイルを展開するのでフォルダを作りたければ、--path=wordpressでパスを指定するとよい。

これでWordpressのファイルが引っ張って来れる。

WordPress設定

次に、wp-config.php ファイルを作成する。

$ wp core config --dbname=testing --dbuser=wp --dbpass=securepswd --locale=ro_RO

WordPress のインストール

config ファイルができたらインストールを実行

$ wp core install --url=example.com --title=Example --admin_user=supervisor --admin_password=strongpassword --admin_email=info@example.com

これでセットアップは完了

Plugins

pluginsのインストールもCLI経由で可能。--activateでデフォルト有効化が可能。

$ wp plugin install contact-form-7 --activate
$ wp plugin install query-monitor --activate
$ wp plugin install wordpress-importer --activate
$ wp plugin install all-in-one-seo-pack --activate

theme

テーマ関係のコマンドはこちら。運用によって様々なパターンが取れそう。

import

WP管理画面からインポート出来ない巨大なインポートファイルもCLI経由ならインポート出来る。

--authorsオプションはユーザのマッピングに関する設定でCSVによるマッピング指定も可能とのこと

$ wp import example.wordpress.2016-06-21.xml --authors=create

運用

wp コマンドはカラントのwp-cli.ymlを読み込み設定として利用する。

よく使用するコマンドの設定などをymlにまとめておくときれいかも

path: wordpress
url: http://localhost:8000
user: admin
color: false

core download:
  locale: ja
  version: 4.5
core config:
    dbuser: root
    dbpass: root
    dbname: wordpress
    dbhost: 127.0.0.1
    extra-php: |
        define( 'WP_DEBUG', true );
        define( 'WP_POST_REVISIONS', 50 );
        define('WP_HOME', 'http://localhost:8000');
        define('WP_SITEURL', 'http://localhost:8000');
        define('WP_LANG', 'ja');
core install:
    admin_user: admin
    url: http://localhost:8000
    admin_password: admin
    admin_email: "t.goto@chatbox-inc.com"
    title: "Wordpress cli test site"

あとはMakefileで、installコマンドなどを記述しておけば、WPの本体を共有する事無くWP環境構築を共有できるっぽい

install:
    wp core download
    wp core config
    wp core install
    wp plugin install contact-form-7 --activate
    wp plugin install query-monitor --activate
    wp plugin install wordpress-importer --activate
    wp plugin install all-in-one-seo-pack --activate

テーマに関してはcomposer installerで上手いことSymlink貼れば良い

環境毎の依存パラメータの変更とかもwp-cli.ymlで上手いこと出来るらしい

5
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
9