×
  • Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
 

WordPress サイト制作におけるデプロイメントを考える ~Git とデプロイメントサービスの活用~

on

  • 271 views

WordCamp Kansai 2014 登壇スライド。

WordCamp Kansai 2014 登壇スライド。
コードのGit管理を前提とし、それを活かしたよりストレスフリーなデプロイメントを紹介しました。紹介したのはツール、サービス、そして最近海外では話題になりつつあるフルスタック系のツールキット。

Slide from my presentation at WordCamp Kansai 2014 (7 June 2014), titled "Considering WordPress Site Deployment - utilizing Git and Deployment Services-"

Statistics

Views

Total Views
271
Views on SlideShare
266
Embed Views
5

Actions

Likes
14
Downloads
1
Comments
0

1 Embed 5

https://twitter.com 6

Accessibility

Categories

Upload Details

Uploaded via SlideShare as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

WordPress サイト制作におけるデプロイメントを考える ~Git とデプロイメントサービスの活用~ WordPress サイト制作におけるデプロイメントを考える ~Git とデプロイメントサービスの活用~ Presentation Transcript

  • WordPress サイト制作における デプロイメントを考える Toru Miki (@waviaei) WordCamp Kansai 2014 ∼Git とデプロイメントサービスの活用∼ 7 June 2014
  • Contributed to:
 - WordPress Core (inline doc)
 - WordPress Japanese package
 - WordCamps as a staff / leading organizer
 - Japanese translations plugins and Codex I have shared through:
 - Blog articles
 - Book 『WordPress 逆引きデザイン辞典PLUS』 Webmaster @ テンプル大学ジャパンキャンパス Toru Miki Toru / @waviaei http://profiles.wordpress.org/Toru
  • スピーカー | WordCamp Kansai 2014
 http://2014.kansai.wordcamp.org/speakers/#wcorg-speaker-miki
  • What is Deploy / Deployment?
  • 定義
  • デプロイとは、主にネットワークを通じて提供されるWeb アプリケーションなどのシステム開発工程において、システ ムを利用可能な状態にすることである。 ! デプロイはソフトウェアのリリースやインストールも含んだ 意味の広い言葉であり、開発環境からステージング環境へシ ステムを反映させることも、ステージング環境から本番環境 へ反映させることも、「デプロイする」と表現できる。 deployとは - IT用語辞典 Weblio辞書
 http://www.weblio.jp/content/deploy
  • 「ウェブサイトをサーバーへアップロードする」
  • Work With Us — Automattic
 http://automattic.com/work-with-us/
  • Deploy という言葉は元々「配置する」「展開する」
 といった意味の英語
  • U.S. Deploys Troops in Search for Kidnapped Nigerian Girls | TIME
 http://time.com/108025/nigeria-chad-boko-haram-american-troops-obama/
  • Today s Agenda
  • 今日は主に Code Deployment の 話をします。
  • Code、つまり テーマやプラグイン、コアなどの ファイルのデプロイメントです。
  • これらのファイルは ! ! で管理できますよね?
  • 今日紹介するのは ! ! でファイル、つまりコードを管理している ことが前提のツールやサービスです。
  • Git でコードを管理している 状況を活かしつつ、 デプロイツールやサービスを活用し、 よりストレスフリーな デプロイメントに挑戦してみましょう。
  • Where should I git init ?
  • WordPress サイトのどの部分を Git の管理下におくか?
  • 特定のテーマのみ cd wp-content/themes/my-theme git init
  • 特定のプラグインのみ cd wp-content/plugins/my-plugin git init
  • サイト全体 cd path/to/wordpress git init ! touch .gitignore
  • gitignore/WordPress.gitignore
 https://github.com/github/gitignore/blob/master/WordPress.gitignore
  • WordPress のデフォルトのファイル構造 のまま git init すると こうなりますよね?
  • サイト全体
  • しかし、 Git で WordPress サイト 全体を管理するのであれば、 次のようなファイル構造のノウハウも シェアされています。
  • サイト全体 WordPress Git サブモジュール wp-content content wp-config.php 開発用・本 番用などに分ける
  • WordPress local dev tips: DB & plugins | Mark on WordPress
 http://markjaquith.wordpress.com/2011/06/24/wordpress-local-dev-tips/
  • WP-Skelton
 https://github.com/markjaquith/WordPress-Skeleton
  • Code Deployment
  • コードのデプロイメントに 特化・対応しているツールやサービスは、 無料・有料を問わず、 既にいろいろあります。
  • でも、 ソフトウェア業界で用いられている ツールがほとんど。
  • 設定が難しい。 多機能。 使いこなすのが難しい。 WordPress サイトにはオーバースペック!
  • でも世界は広い! シンプルなツールやサービスもありました。 シンプルなものから多機能なものまで 主なツールやサービスを 整理してみました。
  • Fabric CI Services
 (Jenkins、
 Travis CI、など) CapistranoMina Dandelion Strano Webistrano Web Service Tool シンプル 多機能
  • Dandelion
  • 機能を限定した シンプル&お手軽な Git 連携型のデプロイツールです。
  • CI Services
 (Jenkins、
 Travis CI、など) Fabric CapistranoMina Strano Webistrano Dandelion Tool 多機能シンプル Web Service
  • Dandelion
 http://scttnlsn.github.io/dandelion/
  • 手動デプロイ Dandelion Local Repository add commit Staging Server
 (TEST) Production Server
 (LIVE)手動デプロイ ローカルリポジトリの HEADをデプロイする
  • ローカル環境にインストール Dandelion gem install dandelion gem install net-sftp 設定ファイルはYAML cd path/to/wordpress git init touch dandelion.yml
  • Dandelion adapter: ftp host: example.com username: user password: pass path: path/to/deployment passive: true ! exclude: - .gitignore - dandelion.yml dandelion.yml FTP SFTP Amazon S3 E.g. さくらのスタンダード
 (デフォルトは false) Dandelion
 http://scttnlsn.github.io/dandelion/ その他の設定可能項目には Docs や Issues を参照
  • コマンドは2つ。オプションは4つ。 Dandelion dandelion status dandelion deploy ! dandelion --repo=[REPO] --config=[CONFIG] --v --h
  • Dandelion dandelion status dandelion deploy
  • Dandelion ロールバック機能は無いが、 deploy で任意のリビジョン指定が可能。
  • ステージングへのデプロイ用 config 本番へのデプロイ用 config Dandelion 1つの YAML ファイル
 = 
 1つのデプロイ先の設定 dandelion deploy dandelion --config=live.yml deploy
  • Deploy & Dploy
  • デプロイに特化したウェブサービスを 2つ紹介します。
  • Fabric CapistranoMina Strano Webistrano CI Services
 (Jenkins、
 Travis CI、など) Dandelion Tool 多機能シンプル Web Service
  • Deploy
 https://www.deployhq.com/
  • dploy
 http://dploy.io/
  • push dploy / Deploy Local Repository Staging Server
 (TEST) Production Server
 (LIVE) 手動・自動デプロイRemote
 Repository 手動・自動デプロイ add commit
  • push Local Repository add commit Staging Server
 (TEST) Production Server
 (LIVE) 手動・自動デプロイRemote
 Repository 手動・自動デプロイ (http://dploy.io) SVN Remote
 Repository
  • push Local Repository add commit Staging Server
 (TEST) Production Server
 (LIVE) 手動・自動デプロイRemote
 Repository 手動・自動デプロイ Staging Server
 (TEST) Production Server
 (LIVE) (http://dploy.io)
  • (http://dploy.io)
  • (http://dploy.io)
  • (http://dploy.io)
  • (http://dploy.io)
  • Deploy と Dploy の2つを紹介しましたが、 同様のサービスは 他にもいろいろあります。
  • FTPLOY
 http://ftploy.com/
  • deploydo
 https://www.deploy.do/
  • wercker
 http://wercker.com/
  • Bamboo
 https://www.atlassian.com/software/bamboo/
  • など… 全て似たようなサービスですが、 仕様が若干違います。
  • Beanstalk & Codebase
  • プライベート Git リポジトリ に デプロイ機能 が付いてくるウェブサービス。
  • Fabric CapistranoMina Strano Webistrano CI Services
 (Jenkins、
 Travis CI、など) Dandelion Tool 多機能シンプル Web Service
  • Beanstalk
 http://beanstalkapp.com/+
  • Developing and Deploying WordPress  •  Beanstalk Guide
 http://guides.beanstalkapp.com/deployments/deploying-wordpress.html
  • Codebase
 http://codebasehq.com/
  • 他にも
  • Springloops
 http://www.springloops.io/
  • Assembla
 https://www.assembla.com/
  • など…
  • Code Deployment Patterns
  • 紹介したツールやサービスを、 想定できるケースに 当てはめてみます。
  • 個人ブログ、テーマのみ Local Repository Production Server
 (LIVE) Dandelion を使って、
 自作テーマやプラグインを
 手動デプロイ。 Dandelion $ cd /my-theme $ git init $ dandelion deploy
  • 個人プロジェクト Local Repository Production Server
 (LIVE) Dandelion Remote
 Repository Staging Server
 (TEST) - SFTP
 - 手動デプロイ - SFTP
 - 手動デプロイ
  • Local Repository Staging Server
 (TEST) Production Server
 (LIVE) Remote
 Repository - SFTP
 - 自動デプロイ - FTP
 - 手動デプロイ 会社で契約しているVPS クライアントが
 契約している
 レンタルサーバー チームで開発 デプロイサービス
  • Staging Server
 (TEST) Production Server
 (LIVE) - staging 用ブランチ
 - 手動・自動デプロイ - production 用ブランチ
 - 手動・自動デプロイ ブランチを作って開発 Remote
 Repository Local Repository OR
  • …という感じで、 想定されるいろいろな使い方に 適用させることが可能です。
  • Dandelion は無料のツール。 デプロイサービスの多くはフリーミアム。
  • Notes*
  • Git の管理下・管理外におくファイル デプロイする・しないファイル
  • Git で管理する Git で管理しない (.gitignore) デプロイする (その他のコアファイル) wp-config.php ? test-config.php ? デプロイしない local-config.php ? wp-config.php ? dandelion.yml ? dandelion.yml ? .htaccess? wp-config.php
  • ファイルのパーミッションと所有者
  • ファイルのパーミッションと所有者 wp-config.php の パーミッションとか chown apache chown nginx
  • 日本のレンタルサーバーは、 日本国外IPアドレスからのアクセスを 制限していることがある。
  • 国外IPアドレスフィルタ|さくらのレンタルサーバ" http://support.sakura.ad.jp/manual/rs/others/ipfilter.html 例:さくらのレンタルサーバ
  • セキュリティ・ポリシー
  • セキュリティ・ポリシー クライアントのコードをサードパー ティーのウェブサービスにアップして問題 ないか? クライアントのサーバー情報を
 サードパーティのウェブサービスに設定して問題 ないか? 情報セキュリティマネジメントシステム ISO 27001 プライバシーマーク
  • Contents Deployment
  • 「これっ!」 と言った決め手がありません。
  • Scripts
  • Scripts URLを適切に置換してくれるスクリプト等と
 組み合わせる。 mysqldump -u user -ppass wp_db > db.sql ! scp rsync
  • WordPress のDB上のサイトURLを一気に変換
 http://dogmap.jp/2012/09/20/wordpress-replace-siteurl/ https://gist.github.com/wokamoto/3627972
  • WordPress Serialized PHP Search Replace Tool
 https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
  • WP-CLI
  • WP-CLI
 http://wp-cli.org/commands/db/ http://wp-cli.org/commands/search-replace/ wp db export wp db import ! wp search-replace 'http://local.dev' 'http://mysite.com' WP-CLIの機能を使う
  • Plugins
  • Contents deployment プラグインはあまり無い。 + 結構いいお値段…
  • WP Migrate DB
 http://wordpress.org/plugins/wp-migrate-db/
  • WP Migrate DB Pro
 https://deliciousbrains.com/wp-migrate-db-pro/
  • WP Migrate DB Pro
 https://deliciousbrains.com/wp-migrate-db-pro/pricing/ https://deliciousbrains.com/wp-migrate-db-pro/videos/
  • Ramp
 http://crowdfavorite.com/ramp/
  • 機能を「同期」ではなく、 サーバーからサーバーへの 「引っ越し」に絞ると、 便利なプラグインが幾つかあります。
  • WordPress Duplicator
 http://wordpress.org/plugins/duplicator/
  • 公開時は引っ越しプラグインを用いて Code と Contents をデプロイ。 ! 公開後は必要時にのみ、 Contents を同期する。 (簡単なバグ修正であれば同期せずに行う。)
  • More Advanced Deployment Tools
  • Capistrano Ruby Mina PHP Fabric Python WordPress 界隈で よく目にする この中では比較的シンプル… Capistrano ほど多機能では…
  • An Introduction To Deploying WordPress with Mina - Tuts
 http://code.tutsplus.com/articles/an-introduction-to-deploying-wordpress-with-mina--wp-34776
  • https://twitter.com/tekapo/status/465656275418619905 http://wp.tekapo.com/2014/03/01/help-me-out-to-translate-fabric-docs/
  • Towards a Full Stack WordPress Development Tool
  • 最後に、Git を前提としたファイル構造の デプロイメントの話から さらに大きい枠の話をします。
  • Git based WordPress setup WP-Skelton Git + WordPress
  • WP-Stack
 https://github.com/markjaquith/WP-Stack
  • Git based WordPress setup WP-Skelton Git + WordPress Toolkit for WordPress Deployment WP-Stack + Code Deployment
  • wp-deploy
 https://github.com/Mixd/wp-deploy
  • Git based WordPress setup WP-Skelton Git + WordPress Toolkit for WordPress Deployment WP-Stack + Code Deployment Framework for deploying WP site using Capistrano 3 wp-deploy + Contents Deployment
  • Genesis Skelton
 https://github.com/genesis/wordpress
  • Bedrock
 http://roots.io/wordpress-stack/
  • Git based WordPress setup WP-Skelton Git + WordPress Toolkit for WordPress Deployment WP-Stack + Code Deployment Framework for deploying WP site using Capistrano 3 we-deploy + Contents Deployment Rapidly create, develop & deploy WP across multi environment Genesis Skelton + Local Dev Environment WordPress Stack Bedrock
  • PHPUnit Test Staging Server
 (TEST) Production Server
 (LIVE) Remote
 Repository PHPUnit Testing & Automation Local Repository 自動デプロイ push
  • + Continuous Integration (CI)
 Services Jenkins Travis CI PHPUnit Test Staging Server
 (TEST) Production Server
 (LIVE) Remote
 Repository PHPUnit Testing & Automation Local Repository 自動デプロイ pull request
  • BuddyPress + Grunt + Travis CI BuddyPress Development Trunk to Adopt a Grunt-Powered Build System
 http://wptavern.com/buddypress-development-trunk-to-adopt-a-grunt-powered-build-system
  • ちなみに、 Git 管理を活かしたデプロイメント ではありませんが、 こういうのもあります…
  • Managed WordPress 
 Hosting
  • いま海外で勢いがある WordPress 専用ホスティングサーバー。 ! 無料でステージング環境を提供し、 アピールポイントにしている サーバーもあります。
  • Media Temple WordPress Hosting
 http://mediatemple.net/webhosting/wordpress/
  • プロダクションサーバーへは1クリックで ファイルとDBをデプロイ。済んだら削除。 Media Temple WordPress Managed Hosting Reviewed : WP Mayor
 http://www.wpmayor.com/media-temple-wordpress-managed-hosting-reviewed/
  • 他にも…
  • WP Engine
 http://wpengine.com/
  • Flywheel
 http://getflywheel.com/
  • ホスティングサーバーに デプロイメント機能もお任せする … プロジェクトによっては、 最良の選択肢かもしれません。
  • Message
  • 何はともあれ Ⅰ.
  • よりストレスフリーなデプロイメントを目指して、 デプロイメントのツールやサービスを使ってみよう。 (車輪の再発明はしない) Ⅱ.
  • Ⅲ. Full Stack 方向を意識しつつ、 情報のアンテナを張り、 手を動かしてみる。
  • Ⅲ. Full Stack 方向を意識しつつ、 情報のアンテナを張り、 手を動かしてみる。 使わなくても、難しくても、 手を動かしておくことで、 理解が深まる、 頭の片隅に記憶しておける!
  • Thank you! http://waviaei.com! @waviaei! waviaei@gmail.com! http://b.hatena.ne.jp/waviaei/wordpress/ That’s All…
  • Photo by Takeshi Kouno https://www.flickr.com/photos/kounotakeshi/13460591725/ https://www.flickr.com/photos/dvids/6093692164p9 p1 cropped & resized Photo by DVIDSHUB cropped & resized Photo Credits