LoginSignup
26
27

More than 5 years have passed since last update.

Yeomanを使ってWordPressの初期構築

Last updated at Posted at 2014-06-11

以前、Composerを使ってのWordPress初期構築をやってみていましたが、YeoPressのほうが簡単便利だったので備忘録として。

今回使うもの

  • node.js
    Yeomanの実行環境
  • npm
    YeomanとYeoPressのインストールに使用
  • Yeoman
    YeoPressの動くベース
  • YeoPress
    WordPressのジェネレータ
  • Composer
    今回使うテーマの初期化で使用
  • Git
    YeoPressでテーマをDLするときに使用

Try

私の使ってるOSはUbuntuなので、別のOSの方はコマンドを適宜読み替えてやってください。

node.jsとnpmの用意出来てない人は

とかを参考に><;

GitとComposerをインストールしてない人はぐぐって(`・ω・´)


Yeomanのインストール

Yeomanってなによ?って方はYeomanのあれこれ - Qiitaを見てみてね。

~$ sudo npm install -g bower grunt-cli yo


YeoPressのインストール

~$ sudo npm install -g generator-wordpress


YeoPressでジェネレート

~/workspace/yeopress-prj/src/html を公開ディレクトリとする体でいきます

$ mkdir -p ~/workspace/yeopress-prj/src/html && cd $_
$ yo wordpress --advanced

Languageの設定にadvancedオプションが必要なので"--advanced"を付けてます。

コマンドを実行すると、対話形式で進みますので適宜入力してください。

                     YeoPress

                 ..::::::::::::..
             .:::   ::::::::::   ::..
           .:    :::::::::::::::    :..
         .:   :::::::::::::::::::::   :.
        .:  ::::::::::::::::::::::     :..
       .:  ::::::::::::::::::::::       ::.
      .:         :::          :::        :..
     .:       ::::::::     :::::::        :.
     :  :      :::::::      :::::::     :  :.
    .:  ::     ::::::::     :::::::    ::  :.
    :: ::::     :::::::      :::::::   ::: ::
    :: ::::     ::::::::     :::::::   ::: ::
    :: :::::     :::::::      ::::::  :::: ::
    :: :::::     ::::::       ::::::  :::: :.
    .:  :::::     :::::  ::    ::::  ::::  :.
     :  ::::::     :::   ::    ::::  ::::  :.
     .:  :::::     ::   :::     ::  ::::  :.
      .:  :::::        :::::    ::  :::  ::.
      .::  ::::       ::::::       :::  ::.
        .:  ::::     ::::::::     :::  ::.
         .:   ::    :::::::::    ::   :.
          .::      ::::::::::      ::.
            ..::    ::::::::    ::..
               ..:::..     ..:::..
                    ..:::::.. 

          A Yeoman Generator For WordPress

[?] WordPress URL: http://yeopress-prj.localhost/
[?] WordPress Version: (3.9.1) 
[?] Table prefix: (wp_) yeopress_prj__wp_ 
[?] Database host: (localhost) 
[?] Database name: any
[?] Database user: root
[?] Database password: xxxx
[?] Language: ja
[?] Use Git? (Y/n) n
[?] Would you like to install WordPress with the custom directory structure? (y/N) y
[?] WordPress install directory: (wordpress) wp
[?] WordPress content directory: (content) 
[?] Create local-config.php? (y/N) y
[?] Block external WP requests? (y/N) 
[?] Use Vagrant? (y/N) 
[?] Install a custom theme? (Y/n) 
[?] Destination directory: (yeopress) original
[?] Theme source type (git/tar) (git) 
[?] GitHub username: (wesleytodd) jhonyspicy
[?] GitHub repository name: (YeoPress) wordpress-theme-base
[?] Repository branch: (template) 
[?] Does this all look correct? (Y/n) 

各質問の簡単な説明

WordPress URL
WordPressを構築するURL
WordPress Version: (3.9.1)
インストールするWordPressのバージョン
Table prefix: (wp_)
WordPressのテーブル名prefix設定です
Database host: (localhost)
データベースのホスト
Database name:
データベースの名前
Database user:
データベースの接続ユーザー名前
Database password:
データベースの接続パスワード
Language:
WordPressの言語設定
指定した言語ファイルのDLもしてくれます
Use Git? (Y/n)
YeoPressを実行したディレクトリをGitリポジトリとするか?
Would you like to install WordPress with the custom directory structure? (y/N)
WordPressをディレクトリに入れるか?
Noだと実行ディレクトリ(今回は~/workspace/yeopress-prj/src/html)に展開されます
WordPress install directory: (wordpress)
WordPressをインストールするディレクトリ
WordPress content directory: (content)
コンテンツを配置するディレクトリ
デフォルトの設定でWordPress使う際のwp-contentディレクトリにあたります
Create local-config.php? (y/N)
wp-config.phpの前にデータベースの接続情報などを書けるファイルを作成するか?
名前の通り、ローカル実行環境の設定をすることを意図していると思います
Block external WP requests? (y/N)
まだよく調べてません
Use Vagrant? (y/N)
まだ使ってみていません
たぶんVagrantfileを用意してくれるのだと思います
Install a custom theme? (Y/n)
カスタムテーマをインストールするか?
Destination directory: (yeopress)
カスタムテーマのインストールディレクトリ名
Theme source type (git/tar) (git)
カスタムテーマのDL方法 git、tarをサポート
GitHub username: (wesleytodd)
カスタムテーマのリポジトリ(Github)のユーザー名
デフォルトはYeoPressの製作者
GitHub repository name: (YeoPress)
カスタムテーマのリポジトリ名
Repository branch: (template)
カスタムテーマのリポジトリのブランチ名
上3つの質問も合わせてデフォルトのカスタムテーマは https://github.com/wesleytodd/YeoPress/tree/template/
Does this all look correct? (Y/n)
今までの入力で間違いないですか?
Noだと最初から入力し直せます
Yesだとジェネレートが開始します

コロンの後に括弧があるものは、未入力⏎で括弧内のものになります。
("y/n"場合は大文字のほうになります。)

なお、回答によっては、ここに無いものが表示されるので、無いものは自分で調べて><;


Composerでカスタムテーマの依存関係解決

カスタムテーマに https://github.com/jhonyspicy/wordpress-theme-base/tree/template を指定したので、最後にComposerでPHPの依存関係を解決してお終いです。

$ cd ~/workspace/yeopress-prj/src/html/content/themes/original/
$ composer install

"composer install"が無事終わればWP Multibyte Patchプラグインなどがpluginsディレクトリにインストールされます。



以上、Yeoman使ってのWordPress初期構築でした。


最後に

不満ってほどじゃないんだけど、local-config.phpをローカル用の1個だけじゃなくて https://github.com/atomita/wordpress-environment-config (手前味噌ですが)みたいに複数環境分けて持てるようにしたら、もっと使いやすいと思う。
プルリクしろって言われそうですがw

26
27
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
26
27