<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cap&#039;n webb &#187; dataich</title>
	<atom:link href="http://blog.dataich.com/author/dataich/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dataich.com</link>
	<description>almost all things about it</description>
	<lastBuildDate>Thu, 12 Jan 2012 03:38:00 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PHPでbundlerぽいことを行うOnion、Composer</title>
		<link>http://blog.dataich.com/2012/01/12/onion-composer/</link>
		<comments>http://blog.dataich.com/2012/01/12/onion-composer/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 03:34:37 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.dataich.com/?p=1145</guid>
		<description><![CDATA[pear.phpunit.de/PHPUnitを依存関係として設定する前提で、Onion、Composerを使ってみました。 Onion PEARモジュールのビルド、コンパイル、そして今回の目的であるbundler的なこ [...]]]></description>
			<content:encoded><![CDATA[<p>pear.phpunit.de/PHPUnitを依存関係として設定する前提で、<a href="https://github.com/c9s/Onion" onclick="pageTracker._trackPageview('/outgoing/github.com/c9s/Onion?referer=');">Onion</a>、<a href="https://github.com/composer/composer" onclick="pageTracker._trackPageview('/outgoing/github.com/composer/composer?referer=');">Composer</a>を使ってみました。</p>
<h3>Onion</h3>
<p>PEARモジュールのビルド、コンパイル、そして今回の目的であるbundler的なことを簡単に行えます。</p>
<h4>インストール</h4>
<h5>homebrewの場合</h5>
<p>gistにFormulaを置きましたので使ってください。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">brew <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">--HEAD</span> https:<span style="color: #000000; font-weight: bold;">//</span>raw.github.com<span style="color: #000000; font-weight: bold;">/</span>gist<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1594321</span><span style="color: #000000; font-weight: bold;">/</span>6769fa97864462c4813f06bbb08760630ba7c87f<span style="color: #000000; font-weight: bold;">/</span>onion.rb</pre></div></div>

<h5>直接</h5>
<p>onion.pharをパスの通ったディレクトリに置いて、実行権限を与えるだけ。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">curl https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>c9s<span style="color: #000000; font-weight: bold;">/</span>Onion<span style="color: #000000; font-weight: bold;">/</span>raw<span style="color: #000000; font-weight: bold;">/</span>master<span style="color: #000000; font-weight: bold;">/</span>onion.phar <span style="color: #000000; font-weight: bold;">&amp;</span>gt; ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>onion.phar</pre></div></div>

<h4>使用方法</h4>
<blockquote><p>
onion_sample<br />
  |&#8211; vendor<br />
  |&#8211; package.ini
</p></blockquote>
<p>プロジェクト直下にpackage.iniを作成し、ここに依存関係などを記述します。<br />
<script type="text/javascript" src="https://gist.github.com/1598335.js?file=package.ini"></script>packageセクションにあるname、desc、version、authorは必須となっています。（そもそもOnionはPEARパッケージを作る際にも使うためだと思われます。） requireセクションに使用したいPEARパッケージを記述します。 上記の状態で下記コマンドを実行することで、vendorディレクトリにPEARパッケージがインストールされます。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ onion.phar <span style="color: #660033;">-d</span> bundle</pre></div></div>

<p>いやー、インストールから実行まで非常に手軽。この手軽さが素晴らしいです。 </p>
<h3>Composer</h3>
<p>こちらもbundler的な事を行えるのですが、Onionよりもその依存関係部分に注力したパッケージマネージャといった感じです。 PEARだけに限らず、gitのリポジトリを依存関係として指定したりもできます。ただその辺りはあまり調べていないので、今回はPEARパッケージのみ使う前提で試して見ました。 </p>
<h4>インストール</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">brew <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">--HEAD</span> https:<span style="color: #000000; font-weight: bold;">//</span>raw.github.com<span style="color: #000000; font-weight: bold;">/</span>gist<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1574469</span><span style="color: #000000; font-weight: bold;">/</span>composer.rb</pre></div></div>

<h4>使用方法</h4>
<blockquote><p>
composer_sample<br />
  |&#8211; vendor<br />
  |&#8211; composer.json
</p></blockquote>
<p>プロジェクト直下にcomposer.jsonを作成し、ここに依存関係などを記述します。<script type="text/javascript" src="https://gist.github.com/1598338.js?file=composer.json"></script></p>
<p>上記の状態で下記コマンドを実行することで、vendorディレクトリにPEARパッケージがインストールされます。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ composer.phar <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>ComposerはPEARモジュール以外も扱うためか、PEARモジュールそのものを扱うのに設定ファイルが少々複雑になります。<br />
今回はpear.phpunit.de/PHPUnitを依存関係として設定していますが、まずそのためにrepositoriesにチャンネルを設定する必要があります。そこまではいいのですが、PHPUnitがpear.symfony-project.com/YAMLに依存しているので、そのチャンネルも記述しておく必要があります。つまり依存関係にある全てのチャンネルを設定しておく必要があるみたいです。これどうにかならないのでしょうか。</p>
<p>雑感としてはPEARモジュールさえ扱えればいいのであれば、Onionの方が簡単だと思いました。対してComposerはPEARモジュール以外にも使えるので、今後に期待できるのはComposerだと思いますが、現状は用途に合わせてといったところでしょう。また気になる動きとして、OnionのGithubリポジトリにcomposer-supportというブランチがあるのが楽しみです。</p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2012/01/12/onion-composer/&via=dataich&text=PHPでbundlerぽいことを行うOnion、Composer&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2012/01/12/onion-composer/_via=dataich_text=PHP_bundler_Onion_Composer_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2012/01/12/onion-composer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpenv+php-build+pyrusでの複数バージョンPHP管理など</title>
		<link>http://blog.dataich.com/2012/01/11/multiple-versions-php-phpenv-phpbuild-pyrus/</link>
		<comments>http://blog.dataich.com/2012/01/11/multiple-versions-php-phpenv-phpbuild-pyrus/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 14:51:42 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.dataich.com/?p=1110</guid>
		<description><![CDATA[必要なもの phpenv PHPのバージョン切り替え（切り替えるのみ、PHPのインストールはできない。rbenvを流用） php-build 複数バージョンPHPのインストールマネージャ Pyrus PEAR後継パッケー [...]]]></description>
			<content:encoded><![CDATA[<h2>必要なもの</h2>
<ul>
<li>phpenv<br />
PHPのバージョン切り替え（切り替えるのみ、PHPのインストールはできない。rbenvを流用）</li>
<li>php-build<br />
複数バージョンPHPのインストールマネージャ</li>
<li>Pyrus<br />
PEAR後継パッケージマネージャ</li>
</ul>
<h2>phpenvのインストール</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ curl https:<span style="color: #000000; font-weight: bold;">//</span>raw.github.com<span style="color: #000000; font-weight: bold;">/</span>CHH<span style="color: #000000; font-weight: bold;">/</span>phpenv<span style="color: #000000; font-weight: bold;">/</span>master<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>phpenv-install.sh <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sh</span>
Installing phpenv <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv
remote: Counting objects: <span style="color: #000000;">1008</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">422</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">422</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">1008</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">633</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">928</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">558</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1008</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1008</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">135.47</span> KiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">124</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">633</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">633</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Success.
&nbsp;
Now add <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>bin to your <span style="color: #007800;">$PATH</span>, add <span style="color: #ff0000;">&quot;eval <span style="color: #007800;">$(phpenv init -)</span>&quot;</span> at the end of your ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc and restart your shell to use phpenv.</pre></div></div>

<p>最後の行で言われたとおり、.bashrcに追記します。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">vi</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #ff0000;">&quot;/Users/dataich/.phpenv/bin:<span style="color: #007800;">$PATH</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(phpenv init -)</span>&quot;</span></pre></div></div>

<p>phpenvは~/.phpenv以下にインストールされており、~/.phpenv/versionsにバージョンごとのPHPをインストールしてやることで切り替えが可能になります。</p>
<h2>php-buildのインストール</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> clone https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>CHH<span style="color: #000000; font-weight: bold;">/</span>php-build.git
$ <span style="color: #7a0874; font-weight: bold;">cd</span> php-build
$ .<span style="color: #000000; font-weight: bold;">/</span>install.sh
Installing php-build <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span>
- Creating Directories... Done.
- Copying files... Done.</pre></div></div>

<p>これで必要なもののインストールは完了です。また、現状はインストールできるPHPバージョンが増えたりした場合は、git pullして./install.shを再度実行しないといけないと思います。</p>
<h2>php-buildを使用してPHPをインストール</h2>
<p>まずはインストール可能なバージョンを調べます。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ php-build <span style="color: #660033;">--definitions</span>
5.2.17
5.3.2
5.3.6
5.3.8
5.3.9RC3
5.3snapshot
5.4.0RC1
5.4.0RC2
5.4.0RC3
5.4.0RC4
5.4.0alpha3
5.4.0beta1
5.4.0beta2
5.4snapshot</pre></div></div>

<p>では上記から好きなバージョンを選んでインストールしています。今回は業務で必須なので5.3.8を。</p>
<h2>とその前にApacheモジュールどうする？</h2>
<p>php-buildはApacheモジュールのビルドに対応していません（GitHubにIssueにはFeatureとして登録されてます。）。<br />
ソースを読んでみるconfigure_optionを呼び出してあげればよさそうです。なのでdefinitionsに定義してあるスクリプトに変更を入れてあげます。このdefinitions配下にあるスクリプトはいろいろビルド方法を調整する時に使えそうです（pyrusじゃなくてpear使いたかったらwith_pear書いて、install_pyrusコメントアウトするとか。）</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>php-build<span style="color: #000000; font-weight: bold;">/</span>definitions<span style="color: #000000; font-weight: bold;">/</span>5.3.8
configure_option <span style="color: #ff0000;">&quot;--with-apxs2&quot;</span> <span style="color: #ff0000;">&quot;/usr/local/Cellar/httpd/2.2.21/sbin/apxs&quot;</span> <span style="color: #666666; font-style: italic;">#この行を追加する。apxsへのパスは環境に応じて置き換えてください。</span>
install_package <span style="color: #ff0000;">&quot;http://www.php.net/distributions/php-5.3.8.tar.bz2&quot;</span>
install_pyrus
&nbsp;
install_xdebug <span style="color: #ff0000;">&quot;2.1.2&quot;</span></pre></div></div>

<p>まあPHPをビルドする度にlibphp5.soを上書きしてしまうだろうということと、phpenvで切り替えた時どうするのっていうのはありますが・・・。</p>
<h2>気をとりなおしてphp-buildを使用してPHPをインストール</h2>
<p>ではphp-buildを使用して5.3.8をインストールします。プレフィックスには~/.phpenv/versions/5.3.8を指定します。実はここでちょっとはまったのですが、最後の引数はプレフィックスなのでフルパスである必要があります。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ php-build 5.3.8 ~<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8
Loaded pyrus Plugin.
Loaded xdebug Plugin.
php.ini-production gets used <span style="color: #c20cb9; font-weight: bold;">as</span> php.ini
&nbsp;
Building 5.3.8 into <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Downloading<span style="color: #7a0874; font-weight: bold;">&#93;</span>: http:<span style="color: #000000; font-weight: bold;">//</span>www.php.net<span style="color: #000000; font-weight: bold;">/</span>distributions<span style="color: #000000; font-weight: bold;">/</span>php-5.3.8.tar.bz2
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Configure<span style="color: #7a0874; font-weight: bold;">&#93;</span>: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>php-build<span style="color: #000000; font-weight: bold;">/</span>source<span style="color: #000000; font-weight: bold;">/</span>5.3.8
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Make<span style="color: #7a0874; font-weight: bold;">&#93;</span>: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>php-build<span style="color: #000000; font-weight: bold;">/</span>source<span style="color: #000000; font-weight: bold;">/</span>5.3.8
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Pyrus<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Downloading from http:<span style="color: #000000; font-weight: bold;">//</span>pear2.php.net<span style="color: #000000; font-weight: bold;">/</span>pyrus.phar
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Pyrus<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Installing executable <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pyrus
<span style="color: #7a0874; font-weight: bold;">&#91;</span>XDebug<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Downloading http:<span style="color: #000000; font-weight: bold;">//</span>xdebug.org<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>xdebug-2.1.2.tgz
<span style="color: #7a0874; font-weight: bold;">&#91;</span>XDebug<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Compiling <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>php-build<span style="color: #000000; font-weight: bold;">/</span>source<span style="color: #000000; font-weight: bold;">/</span>xdebug-2.1.2
<span style="color: #7a0874; font-weight: bold;">&#91;</span>XDebug<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Installing XDebug configuration <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>conf.d<span style="color: #000000; font-weight: bold;">/</span>xdebug.ini
<span style="color: #7a0874; font-weight: bold;">&#91;</span>XDebug<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Cleaning up.
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Info<span style="color: #7a0874; font-weight: bold;">&#93;</span>: The Log File is not empty, but the Build did not fail. Maybe just warnings got logged. You can review the log <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>php-build<span style="color: #000000; font-weight: bold;">/</span>error.5.3.8.20120106174319.log
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Success<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Built 5.3.8 successfully.</pre></div></div>

<p>ちなみにphp.iniは~/.phpenv/versions/5.3.8/etc配下のを使うようになっています。また~/.phpenv/versions/5.3.8/etc/conf.d配下のものも読むようになっており、xdebug.iniなどが置いてあります。バージョンごとにiniファイルを持っているので便利です。</p>
<h2>phpenvを使ってみる</h2>
<p>ではphpenvにて切り替えられるバージョンを調べてみます。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ phpenv versions
5.3.8</pre></div></div>

<p>先ほどインスールした5.3.8が使用できる状態になっていますので、グローバルに使うようにします。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ phpenv global 5.3.8
$ phpenv versions
<span style="color: #000000; font-weight: bold;">*</span> 5.3.8 <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">set</span> by <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.rbenv-version<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$ php <span style="color: #660033;">-v</span>
PHP 5.3.8 <span style="color: #7a0874; font-weight: bold;">&#40;</span>cli<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>built: Jan <span style="color: #000000;">11</span> <span style="color: #000000;">2012</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">20</span>:<span style="color: #000000;">46</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">1997</span>-<span style="color: #000000;">2011</span> The PHP Group
Zend Engine v2.3.0, Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">1998</span>-<span style="color: #000000;">2011</span> Zend Technologies
with Xdebug v2.1.2, Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">2002</span>-<span style="color: #000000;">2011</span>, by Derick Rethans</pre></div></div>

<p>また、下記のようにlocalを使うとカレントディレクトリに.rbenv-versionというファイルが作られ、そのディレクトリ配下では一度指定したバージョンが使われるようになります。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ phpenv <span style="color: #7a0874; font-weight: bold;">local</span> 5.4snapshot</pre></div></div>

<h2>phpenv rehashコマンド</h2>
<p>phpenvでは.phpenv/shims/にパスを通すようになっており、そこを介してexecutableなコマンドを実行したりします。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ll .phpenv<span style="color: #000000; font-weight: bold;">/</span>shims</pre></div></div>

<p>何もないはずです。ここを構築するにはrehashを使います。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ phpenv rehash
$ ll .phpenv<span style="color: #000000; font-weight: bold;">/</span>shims<span style="color: #000000; font-weight: bold;">/</span>
total <span style="color: #000000;">56</span>
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">7</span> dataich staff <span style="color: #000000;">102</span> <span style="color: #000000;">1</span> <span style="color: #000000;">11</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span> phar
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">7</span> dataich staff <span style="color: #000000;">102</span> <span style="color: #000000;">1</span> <span style="color: #000000;">11</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span> phar.phar
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">7</span> dataich staff <span style="color: #000000;">102</span> <span style="color: #000000;">1</span> <span style="color: #000000;">11</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span> php
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">7</span> dataich staff <span style="color: #000000;">102</span> <span style="color: #000000;">1</span> <span style="color: #000000;">11</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span> php-config
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">7</span> dataich staff <span style="color: #000000;">102</span> <span style="color: #000000;">1</span> <span style="color: #000000;">11</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span> phpize
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">7</span> dataich staff <span style="color: #000000;">102</span> <span style="color: #000000;">1</span> <span style="color: #000000;">11</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span> pyrus
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">7</span> dataich staff <span style="color: #000000;">102</span> <span style="color: #000000;">1</span> <span style="color: #000000;">11</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">31</span> pyrus.phar</pre></div></div>

<p>これを実行することでインストールされているPHPやPEARモジュールの実体を探してきて、シムリンクぽいシェルスクリプトが作成されます。新しいバージョンのPHPや、phpunitなどの実行モジュールをインストールした後には実行しておきましょう。</p>
<h2>Pyrus</h2>
<p>で次にPyrusです。PEARの後継にあたるパッケージマネージャです。使ってみます。<br />
php-buildでインストールした際に既に使えるようになっています。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ pyrus config-show
Pyrus version 2.0.0a3 SHA-<span style="color: #000000;">1</span>: BE7EA9D171AE3873F1BBAF692EEE9165BB14BD5D
Using PEAR installation found at <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>pyrus
System paths:
php_dir =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>pyrus<span style="color: #000000; font-weight: bold;">/</span>php
ext_dir =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>extensions<span style="color: #000000; font-weight: bold;">/</span>no-debug-non-zts-<span style="color: #000000;">20090626</span>
cfg_dir =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>pyrus<span style="color: #000000; font-weight: bold;">/</span>cfg
doc_dir =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>pyrus<span style="color: #000000; font-weight: bold;">/</span>docs
bin_dir =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>
data_dir =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>pyrus<span style="color: #000000; font-weight: bold;">/</span>data
www_dir =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>pyrus<span style="color: #000000; font-weight: bold;">/</span>www
test_dir =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>pyrus<span style="color: #000000; font-weight: bold;">/</span>tests
src_dir =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>pyrus<span style="color: #000000; font-weight: bold;">/</span>src
php_bin =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php
php_ini =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini
php_prefix =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dataich<span style="color: #000000; font-weight: bold;">/</span>.phpenv<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>
php_suffix =<span style="color: #000000; font-weight: bold;">&gt;</span>
...</pre></div></div>

<p>パッケージのインストール先ディレクトリ等がphpenvで指定している現在のバージョン配下になっています、素晴らしい！これでPEARモジュールは現在使用中のPHPのバージョン配下に収まることになります。</p>
<p>pyrusコマンドは第一引数にディレクトリを渡してやることで、そのディレクトリローカルなパッケージ管理ができるようになるので、非常に便利です。ただphp-buildが生成するshimにバグがあって、使えない状態だったのですが、作者さんに投げたところ数時間で対応していただきました、これで常用できそうです。<br />
<a href="https://github.com/CHH/php-build/issues/35" onclick="pageTracker._trackPageview('/outgoing/github.com/CHH/php-build/issues/35?referer=');">#35: Cannot use pyrus locally &#8211; Issues &#8211; CHH/php-build &#8211; GitHub</a></p>
<p>ただし現状Pyrusだとプロジェクトローカルなインストールは簡単なのですが、依存関係の設定ファイルだけリポジトリに上げておいて、コマンド一発で全部インストールみたいなことが難しいです。package.xmlを作ればできるようなのですが、そもそもPEARモジュールのビルド用ぽくて、扱いが難しいです。次のエントリーではその辺りを上手く解決してくれる、Onion、Composer辺り扱ってみます。</p>
<h2>参考</h2>
<p><a href="http://blog.yuyat.jp/archives/1446" onclick="pageTracker._trackPageview('/outgoing/blog.yuyat.jp/archives/1446?referer=');">phpenv で複数の PHP 環境を管理する</a><br />
<a href="http://blog.yuyat.jp/archives/1376" onclick="pageTracker._trackPageview('/outgoing/blog.yuyat.jp/archives/1376?referer=');">php-build で PHP 5.4.0 beta1 をビルドする</a><br />
<a href="http://saltybeagle.com/2011/01/using-pyrus-to-manage-pear-installable-vendor-libs/" onclick="pageTracker._trackPageview('/outgoing/saltybeagle.com/2011/01/using-pyrus-to-manage-pear-installable-vendor-libs/?referer=');">Using Pyrus To Manage PEAR Installable Vendor Libs</a></p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2012/01/11/multiple-versions-php-phpenv-phpbuild-pyrus/&via=dataich&text=phpenv+php-build+pyrusでの複数バージョンPHP管理など&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2012/01/11/multiple-versions-php-phpenv-phpbuild-pyrus/_via=dataich_text=phpenv+php-build+pyrus_PHP_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2012/01/11/multiple-versions-php-phpenv-phpbuild-pyrus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPUnit_Storyで振舞駆動開発なテストを書いてみた</title>
		<link>http://blog.dataich.com/2011/12/09/bdd-with-phpunit_story/</link>
		<comments>http://blog.dataich.com/2011/12/09/bdd-with-phpunit_story/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 15:06:57 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPUnit]]></category>
		<category><![CDATA[テスト]]></category>

		<guid isPermaLink="false">http://blog.dataich.com/?p=1096</guid>
		<description><![CDATA[テスト対象としてEntryクラスを作成しました。 ステータス（下書き・公開済・削除）を持つ。 初期ステータスは下書き ステータスはメソッドを通じて変更できる。 まずはテスト駆動開発なテストを行う簡単なテストケースを書いて [...]]]></description>
			<content:encoded><![CDATA[<p>テスト対象としてEntryクラスを作成しました。</p>
<ul>
<li>ステータス（下書き・公開済・削除）を持つ。</li>
<li>初期ステータスは下書き</li>
<li>ステータスはメソッドを通じて変更できる。</li>
</ul>
<p><script src="https://gist.github.com/1447145.js?file=Entry.php"></script></p>
<div>まずはテスト駆動開発なテストを行う簡単なテストケースを書いてみました。こんなコードになります。</div>
<p><script src="https://gist.github.com/1447145.js?file=EntryTest.php"></script></p>
<div>実行結果はこうなります。</div>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ phpunit <span style="color: #660033;">--debug</span> EntryTest.php 
PHPUnit 3.6.2 by Sebastian Bergmann.
&nbsp;
&nbsp;
Starting <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #ff0000;">'EntryTest::testStatus'</span>.
.
&nbsp;
Time: <span style="color: #000000;">0</span> seconds, Memory: 5.50Mb
&nbsp;
OK <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">test</span>, <span style="color: #000000;">3</span> assertions<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>これを振舞駆動開発なテストで書きなおしてみました。PHPUnit_Extensions_Story_TestCaseをextendsし、runGiven、runWhen、runThenを実装する必要があります。<br />
<script src="https://gist.github.com/1447145.js?file=EntrySpec.php"></script></p>
<div>実行結果はこうです。なんかそれっぽくなりました</div>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ phpunit <span style="color: #660033;">--debug</span> <span style="color: #660033;">--verbose</span> <span style="color: #660033;">--printer</span> PHPUnit_Extensions_Story_ResultPrinter_Text EntrySpec.php
PHPUnit 3.6.2 by Sebastian Bergmann.
&nbsp;
EntrySpec
 <span style="color: #7a0874; font-weight: bold;">&#91;</span>x<span style="color: #7a0874; font-weight: bold;">&#93;</span> Status <span style="color: #000000; font-weight: bold;">for</span> new entry is draft
&nbsp;
   Given New Entry 
    Then Status should be draft
&nbsp;
 <span style="color: #7a0874; font-weight: bold;">&#91;</span>x<span style="color: #7a0874; font-weight: bold;">&#93;</span> Status after publish entry is published
&nbsp;
   Given Some Entry 
    When publish Entry 
    Then Status should be published
&nbsp;
 <span style="color: #7a0874; font-weight: bold;">&#91;</span>x<span style="color: #7a0874; font-weight: bold;">&#93;</span> Status after delete entry is deleted
&nbsp;
   Given Some Entry 
    When delete Entry 
    Then Status should be deleted
&nbsp;
Scenarios: <span style="color: #000000;">3</span>, Failed: <span style="color: #000000;">0</span>, Skipped: <span style="color: #000000;">0</span>, Incomplete: <span style="color: #000000;">0</span>.</pre></div></div>

<p>パッと見、コード量が多くなってしまいましたが、テスト対象がサンプル程度なので。実装が増えてきたときに、runGiven、runWhen、runThenを良い感じに使いまわせるようにすると、効果大きそうです。<br />
ちなみにPHPUnit、PHPUnit_StoryともにPEARでサクッとインストール可能です。</p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2011/12/09/bdd-with-phpunit_story/&via=dataich&text=PHPUnit_Storyで振舞駆動開発なテストを書いてみた&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2011/12/09/bdd-with-phpunit_story/_via=dataich_text=PHPUnit_Story_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2011/12/09/bdd-with-phpunit_story/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HomebrewでApache2.2+MySQL5.1+PHP5.3環境を構築</title>
		<link>http://blog.dataich.com/2011/11/01/install-apache2-2-mysql5-1php5-3-using-homebrew/</link>
		<comments>http://blog.dataich.com/2011/11/01/install-apache2-2-mysql5-1php5-3-using-homebrew/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 13:48:09 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Homebrew]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.dataich.com/?p=1081</guid>
		<description><![CDATA[残念ながらHomebrewのリポジトリにはApache、PHPがなく、MySQLは5.5となっています。もっともApacheとPHPに関しては、システムに入ってるものはインストールしないというHomebrewの方針なんだ [...]]]></description>
			<content:encoded><![CDATA[<p>残念ながらHomebrewのリポジトリにはApache、PHPがなく、MySQLは5.5となっています。もっともApacheとPHPに関しては、システムに入ってるものはインストールしないというHomebrewの方針なんだろうと思いますが。で探し回っているとこんなものを見つけました。</p>
<blockquote><p>Alternate formulae repos for Homebrew<br />
<a href="https://github.com/adamv/homebrew-alt/" onclick="pageTracker._trackPageview('/outgoing/github.com/adamv/homebrew-alt/?referer=');">https://github.com/adamv/homebrew-alt/</a></p></blockquote>
<p>homebrewのリポジトリにはないものを野良的に公開してくださっています。上記利用させていただいて、MAMP環境を構築します。</p>
<h3>PHP5.3のインストール</h3>
<p>HomebrewはFomulaの直URL指定でもインストールすることができます。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">brew <span style="color: #c20cb9; font-weight: bold;">install</span> https:<span style="color: #000000; font-weight: bold;">//</span>raw.github.com<span style="color: #000000; font-weight: bold;">/</span>adamv<span style="color: #000000; font-weight: bold;">/</span>homebrew-alt<span style="color: #000000; font-weight: bold;">/</span>master<span style="color: #000000; font-weight: bold;">/</span>duplicates<span style="color: #000000; font-weight: bold;">/</span>php.rb <span style="color: #660033;">--with-mysql</span></pre></div></div>

<p>ちなみにduplicatesディレクトリに入っているFomulaは、OS Xに標準で入っているものが集められています。</p>
<h3>MySQL5.1のインストール</h3>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">brew <span style="color: #c20cb9; font-weight: bold;">install</span> https:<span style="color: #000000; font-weight: bold;">//</span>raw.github.com<span style="color: #000000; font-weight: bold;">/</span>adamv<span style="color: #000000; font-weight: bold;">/</span>homebrew-alt<span style="color: #000000; font-weight: bold;">/</span>master<span style="color: #000000; font-weight: bold;">/</span>versions<span style="color: #000000; font-weight: bold;">/</span>mysql51.rb <span style="color: #660033;">--with-utf8-default</span> <span style="color: #660033;">--use-gcc</span></pre></div></div>

<h5>初期設定</h5>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">unset</span> TMPDIR
mysql_install_db</pre></div></div>

<h5>起動・停止</h5>
<p>私は、自動起動はさせたくなかったので、launchdには登録しませんでした。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql.server start
mysql.server stop</pre></div></div>

<h3>Apache2.2のインストール</h3>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">brew <span style="color: #c20cb9; font-weight: bold;">install</span> https:<span style="color: #000000; font-weight: bold;">//</span>raw.github.com<span style="color: #000000; font-weight: bold;">/</span>adamv<span style="color: #000000; font-weight: bold;">/</span>homebrew-alt<span style="color: #000000; font-weight: bold;">/</span>master<span style="color: #000000; font-weight: bold;">/</span>duplicates<span style="color: #000000; font-weight: bold;">/</span>httpd.rb</pre></div></div>

<p>httpd.conf等は/usr/local/Cellar/httpd/2.2.21/etc/apache2にあります。</p>
<h5>PHPなどの設定</h5>
<p>私の場合は、extra/php.confを作成し、httpd.confにてIncludeするようにしています。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>2.2.21<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>extra<span style="color: #000000; font-weight: bold;">/</span>php.conf</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LoadModule php5_module <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>libphp5.so
AddType application<span style="color: #000000; font-weight: bold;">/</span>x-httpd-php .php .php5 .phtml</pre></div></div>

<p>その他に、DocumentRootを/Users/dataich/Sitesという風にユーザーホームのSitesディレクトリを使用するようにしました。この辺りはお好みで。</p>
<h5>起動・停止</h5>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> apachectl start
<span style="color: #c20cb9; font-weight: bold;">sudo</span> apachectl stop</pre></div></div>

<p>あとは、phpinfo()で出力してみたりして確認すればOKです。</p>
<p><strong>追記 &#8211; 2011/11/08</strong><br />
Homebrewで入れたPHPのpearでpermissionエラーが出ましたので、下記でもろもろ設定しました。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> ug+<span style="color: #c20cb9; font-weight: bold;">w</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>php
pear config-set php_ini <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></div></div>

<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2011/11/01/install-apache2-2-mysql5-1php5-3-using-homebrew/&via=dataich&text=HomebrewでApache2.2+MySQL5.1+PHP5.3環境を構築 &related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2011/11/01/install-apache2-2-mysql5-1php5-3-using-homebrew/_via=dataich_text=Homebrew_Apache2.2+MySQL5.1+PHP5.3_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2011/11/01/install-apache2-2-mysql5-1php5-3-using-homebrew/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>「じゃばすく製作所（仮）ひとつめ」で話してきました</title>
		<link>http://blog.dataich.com/2011/10/23/javascript-factory/</link>
		<comments>http://blog.dataich.com/2011/10/23/javascript-factory/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 14:32:03 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.dataich.com/?p=1071</guid>
		<description><![CDATA[じゃばすく製作所（仮）ひとつめ というわけで、「じゃばすく製作所（仮）ひとつめ」で話してきました。 コンテンツのアウトラインは@tactactadさんに作ってもらい、中身は僕が書いたという感じです。前半僕がJavaScr [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><a href="http://atnd.org/events/20731" onclick="pageTracker._trackPageview('/outgoing/atnd.org/events/20731?referer=');">じゃばすく製作所（仮）ひとつめ</a></p></blockquote>
<p>というわけで、「じゃばすく製作所（仮）ひとつめ」で話してきました。</p>
<p>コンテンツのアウトラインは<a href="http://twitter.com/#!/tactactad" onclick="pageTracker._trackPageview('/outgoing/twitter.com/_/tactactad?referer=');">@tactactad</a>さんに作ってもらい、中身は僕が書いたという感じです。前半僕がJavaScriptについて説明、後半は皆さんに計算機を作ってもらうというコンテンツでした。</p>
<p>JavaScriptの基本の説明の部分では、関数のちょっと深い部分やプロトタイプチェーンなどの説明もやったのですが、非プログラマな方々もいらっしゃったので、ちょっと申し訳なかったです。もう少し後半の計算機制作に向けて特化した内容にしても良かったのかなあという気がします。もうこればっかりは経験。やっていくしかない。</p>
<p>スライドは<a href="http://dl.dropbox.com/u/126064/nagasaki-it/JavaScript.html" onclick="pageTracker._trackPageview('/outgoing/dl.dropbox.com/u/126064/nagasaki-it/JavaScript.html?referer=');">Dropbox</a>に置いてますのでどうぞ。</p>
<p>&nbsp;</p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2011/10/23/javascript-factory/&via=dataich&text=「じゃばすく製作所（仮）ひとつめ」で話してきました&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2011/10/23/javascript-factory/_via=dataich_text=_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2011/10/23/javascript-factory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CORESERVERからdotCloudにWordPressをお引っ越し</title>
		<link>http://blog.dataich.com/2011/08/02/wordpress-on-coreserver-to-dotcloud/</link>
		<comments>http://blog.dataich.com/2011/08/02/wordpress-on-coreserver-to-dotcloud/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 13:03:48 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[dotCloud]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://blog.dataich.com/?p=1039</guid>
		<description><![CDATA[dotCloudがプライベートベータから正式リリースに至り、ベータの頃からのユーザには1年間のProアカウントを発行してくれるということで、PaaSの運用テストを兼ねて、引っ越してみることにしました。個人ではお高いのでず [...]]]></description>
			<content:encoded><![CDATA[<p>dotCloudがプライベートベータから正式リリースに至り、ベータの頃からのユーザには1年間のProアカウントを発行してくれるということで、PaaSの運用テストを兼ねて、引っ越してみることにしました。個人ではお高いのでずっとは使えませんが。。。</p>
<h3>CORESERVERでやること</h3>
<p>まずは、CORESERVER側のWordpressを本体、プラグインともに最新にアップデートしました。<br />
この状態でCORESERVERの管理画面からWordpressデータベースのダンプを取ってローカルに持ってきます。<br />
また、CORESERVER上のWordpressディレクトリもごっそりローカルに持ってきました。</p>
<h3>dotCloud基本設定</h3>
<p>ここからがdotCloudに対して行う作業です。<br />
ここではアプリケーション名をwordpressとしています。</p>
<p>dotCloudにアプリケーションを作成します。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ dotcloud create wordpress
Created application <span style="color: #ff0000;">&quot;wordpress&quot;</span></pre></div></div>

<p>ローカルにディレクトリを作成します。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> blog.dataich.com</pre></div></div>

<p>ここにサービスの設定や、ソースコード等を置いていきます。</p>
<p>WordPressに必要なサービスPHP、MySQLの設定を行います。dotcloud.ymlに記述します。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ <span style="color: #c20cb9; font-weight: bold;">vi</span> blog.dataich.com<span style="color: #000000; font-weight: bold;">/</span>dotcloud.yml</pre></div></div>

<p><script type="text/javascript" src="https://gist.github.com/1119565.js?file=dotcloud.yml"></script></p>
<p>まずはこの状態で動きを確認してみます。 dotcloud pushコマンドでアプリケーションのソースコード（とはいってもこの段階ではdotcloud.ymlのみ）をPushします。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ dotcloud push wordpress blog.dataich.com
<span style="color: #666666; font-style: italic;"># upload blog.dataich.com ssh://dotcloud@uploader.dotcloud.com:21122/wordpress</span>
<span style="color: #666666; font-style: italic;"># rsync</span>
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added <span style="color: #ff0000;">'[uploader.dotcloud.com]:21122,[184.73.14.49]:21122'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>RSA<span style="color: #7a0874; font-weight: bold;">&#41;</span> to the list of known hosts.
building <span style="color: #c20cb9; font-weight: bold;">file</span> list ... <span style="color: #000000; font-weight: bold;">done</span>
.<span style="color: #000000; font-weight: bold;">/</span>
dotcloud.yml
&nbsp;
sent <span style="color: #000000;">188</span> bytes  received <span style="color: #000000;">54</span> bytes  <span style="color: #000000;">9.88</span> bytes<span style="color: #000000; font-weight: bold;">/</span>sec
total <span style="color: #c20cb9; font-weight: bold;">size</span> is <span style="color: #000000;">52</span>  speedup is <span style="color: #000000;">0.21</span>
Deployment <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #ff0000;">&quot;wordpress&quot;</span> triggered. Will be available <span style="color: #000000; font-weight: bold;">in</span> a few seconds.
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:04:<span style="color: #000000;">54</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>api<span style="color: #7a0874; font-weight: bold;">&#93;</span> Waiting <span style="color: #000000; font-weight: bold;">for</span> the build. <span style="color: #7a0874; font-weight: bold;">&#40;</span>It may take a few minutes<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:04:<span style="color: #000000;">54</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Deploying...
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:04:<span style="color: #000000;">54</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>data.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Deploying...
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">25</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Service booted
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">35</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>data.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Service booted
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">35</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>api<span style="color: #7a0874; font-weight: bold;">&#93;</span> All the services are ready. Beginning the build.
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">36</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>data.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> The build started
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">36</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>data.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> This service <span style="color: #7a0874; font-weight: bold;">type</span> does not support build method, ignoring...
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">36</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>data.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> The build finished successfully
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">36</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> The build started
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">36</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Fetched code revision rsync-<span style="color: #000000;">1312214692.31</span>
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">37</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Updating channel <span style="color: #ff0000;">&quot;doc.php.net&quot;</span>
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">37</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Update of Channel <span style="color: #ff0000;">&quot;doc.php.net&quot;</span> succeeded
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">37</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Updating channel <span style="color: #ff0000;">&quot;pear.php.net&quot;</span>
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">38</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Channel <span style="color: #ff0000;">&quot;pear.php.net&quot;</span> is up to <span style="color: #c20cb9; font-weight: bold;">date</span>
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">38</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Updating channel <span style="color: #ff0000;">&quot;pecl.php.net&quot;</span>
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">38</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Update of Channel <span style="color: #ff0000;">&quot;pecl.php.net&quot;</span> succeeded
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">38</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> -su: line <span style="color: #000000;">0</span>: <span style="color: #7a0874; font-weight: bold;">cd</span>: current: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">39</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> -su: line <span style="color: #000000;">0</span>: <span style="color: #7a0874; font-weight: bold;">cd</span>: current: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">39</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> Reloading nginx configuration: nginx.
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">42</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> php5-fpm: stopped
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">42</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> php5-fpm: ERROR <span style="color: #7a0874; font-weight: bold;">&#40;</span>abnormal termination<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">42</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>www.0<span style="color: #7a0874; font-weight: bold;">&#93;</span> The build finished successfully
<span style="color: #000000;">2011</span>-08-01 <span style="color: #000000;">23</span>:05:<span style="color: #000000;">42</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>api<span style="color: #7a0874; font-weight: bold;">&#93;</span> Deploy finished
&nbsp;
Deployment finished. Your application is available at the following URLs
www: http:<span style="color: #000000; font-weight: bold;">//</span>xxxxxxxx.dotcloud.com<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>最後の行にサービスwww（PHP）のURLが発行されているので、アクセスしてみます。当然何のリソースもPushしていないので、404が返ってくるかと思います。</p>
<h3>データの移行</h3>
<p>CORESERVERからとったデータベースダンプをdotCloud上のMySQLにロードします。そのためにdotCloudにデータベース、ユーザの作成をしておきます。</p>
<p>まずは、dotcloud infoでMySQLサービスの情報を取得します。ここでは書きませんが、rootパスワードその他情報が表示されるはずです。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ dotcloud info wordpress.data</pre></div></div>

<p>次のコマンドでMySQLのシェルにログインします。</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">dataich:dev dataich$ dotcloud run wordpress.<span style="color: #990099; font-weight: bold;">data</span> <span style="color: #808080; font-style: italic;">-- mysql -u root -p</span>
<span style="color: #808080; font-style: italic;"># mysql -u root -p</span>
Warning: Permanently added <span style="color: #008000;">'[xxxxxxxx.dotcloud.com]:12428,[174.129.17.131]:12428'</span> <span style="color: #FF00FF;">&#40;</span>RSA<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">to</span> the list of known hosts.
Enter <span style="color: #000099;">password</span>:
Welcome <span style="color: #990099; font-weight: bold;">to</span> the MySQL monitor.  Commands <span style="color: #009900;">end</span> <span style="color: #990099; font-weight: bold;">with</span> <span style="color: #000033;">;</span> <span style="color: #CC0099; font-weight: bold;">or</span> \g.
Your MySQL <span style="color: #FF9900; font-weight: bold;">connection</span> id <span style="color: #CC0099; font-weight: bold;">is</span> <span style="color: #008080;">34</span>
Server <span style="color: #000099;">version</span>: 5.1.41<span style="color: #CC0099;">-</span>3ubuntu12.10<span style="color: #CC0099;">-</span><span style="color: #000099;">log</span> <span style="color: #FF00FF;">&#40;</span>Ubuntu<span style="color: #FF00FF;">&#41;</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">Type</span> <span style="color: #008000;">'help;'</span> <span style="color: #CC0099; font-weight: bold;">or</span> <span style="color: #008000;">'<span style="color: #004000; font-weight: bold;">\h</span>'</span> for <span style="color: #990099; font-weight: bold;">help</span>. <span style="color: #990099; font-weight: bold;">Type</span> <span style="color: #008000;">'<span style="color: #004000; font-weight: bold;">\c</span>'</span> <span style="color: #990099; font-weight: bold;">to</span> clear the current input statement.
&nbsp;
mysql<span style="color: #CC0099;">&gt;</span></pre></div></div>

<p>DBを作成します。</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">DATABASE</span> wordpress<span style="color: #000033;">;</span>
Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">1</span> row affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div>

<p>ユーザを作成し、権限を与えます。</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">GRANT</span> <span style="color: #990099; font-weight: bold;">ALL</span> <span style="color: #990099; font-weight: bold;">ON</span> wordpress.<span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">TO</span> <span style="color: #008000;">'dataich'</span>@<span style="color: #008000;">'<span style="color: #008080; font-weight: bold;">%</span>'</span> IDENTIFIED BY <span style="color: #008000;">'XXXXXXXXXX'</span><span style="color: #000033;">;</span>
Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">0</span> rows affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div>

<p>念のため</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> FLUSH <span style="color: #990099; font-weight: bold;">PRIVILEGES</span><span style="color: #000033;">;</span>
Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">0</span> rows affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div>

<p>では、データをロードします。 データをアップし</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ dotcloud run wordpress.data <span style="color: #ff0000;">&quot;cat &gt; data.sql&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>mysql_wp.dump
<span style="color: #666666; font-style: italic;"># cat &gt; data.sql</span>
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added <span style="color: #ff0000;">'[xxxxxxxx.dotcloud.com]:12428,[174.129.17.131]:12428'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>RSA<span style="color: #7a0874; font-weight: bold;">&#41;</span> to the list of known hosts.</pre></div></div>

<p>SSHログインし</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ dotcloud <span style="color: #c20cb9; font-weight: bold;">ssh</span> wordpress.data
<span style="color: #666666; font-style: italic;"># $SHELL</span>
Warning: Permanently added <span style="color: #ff0000;">'[xxxxxxxx.dotcloud.com]:12428,[174.129.17.131]:12428'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>RSA<span style="color: #7a0874; font-weight: bold;">&#41;</span> to the list of known hosts.
mysql<span style="color: #000000; font-weight: bold;">@</span>wordpress-default-data-<span style="color: #000000;">0</span>:~$</pre></div></div>

<p>ロードします。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql<span style="color: #000000; font-weight: bold;">@</span>wordpress-default-data-<span style="color: #000000;">0</span>:~$ mysql <span style="color: #660033;">-u</span> dataich <span style="color: #660033;">-p</span> wordpress <span style="color: #000000; font-weight: bold;">&lt;</span> data.sql</pre></div></div>

<h3>WordPressソースの移行</h3>
<p>アプリケーションのディレクトリにwwwというディレクトリを作り、そこにCORESEVERから持ってきたソースを置きます。</p>
<p>DBの設定を行うため、wp-config.phpを編集します。<br />
dotcloudでは/home/dotcloud/environment.jsonに各種サービスの設定が書かれます。それを読むようにしてあげればOKです。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ <span style="color: #c20cb9; font-weight: bold;">vi</span> blog.dataich.com<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>wp-config.php</pre></div></div>

<p><script src="https://gist.github.com/1119568.js?file=wp-config.php"></script></p>
<h3>nginxの設定</h3>
<p>パーマリンク設定をp=123の形から変えている場合は、nginxの設定が必要になります。それにはnginx.confを置いてあげればOKです。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ <span style="color: #c20cb9; font-weight: bold;">vi</span> blog.dataich.com<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>nginx.conf</pre></div></div>

<p><script type="text/javascript" src="https://gist.github.com/1119570.js?file=nginx.conf"></script></p>
<h3>wp-contentディレクトリの扱い</h3>
<p>このままだと1回目以降にPushした際にwp-content以下が消えてしまいます。それではまずいので、すでにwp-contentディレクトリが存在する場合は何もしないようにpostinstallスクリプトを書いておきます。（dotcloudのヘルプそのまんま）</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ <span style="color: #c20cb9; font-weight: bold;">vi</span> blog.dataich.com<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>postinstall</pre></div></div>

<p><script src="https://gist.github.com/1119572.js?file=postinstall"></script></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x blog.dataich.com<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>postinstall</pre></div></div>

<h3>dotCloudへWordpressソースをPush</h3>
<p>これで、動くはず！さあ、Push!!!</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:dev dataich$ dotcloud push wordpress blog.dataich.com
<span style="color: #666666; font-style: italic;"># upload blog.dataich.com ssh://dotcloud@uploader.dotcloud.com:21122/wordpress</span>
<span style="color: #666666; font-style: italic;"># rsync</span>
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added <span style="color: #ff0000;">'[uploader.dotcloud.com]:21122,[184.73.14.49]:21122'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>RSA<span style="color: #7a0874; font-weight: bold;">&#41;</span> to the list of known hosts.
building <span style="color: #c20cb9; font-weight: bold;">file</span> list ... <span style="color: #000000; font-weight: bold;">done</span>
.<span style="color: #000000; font-weight: bold;">/</span>
www<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
..
..
..
&nbsp;
www: http:<span style="color: #000000; font-weight: bold;">//</span>xxxxxxxx.dotcloud.com<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>上記、URLに正しくアクセスできました。</p>
<h3>カスタムドメインの設定</h3>
<p>まずはdotCloud側を設定します。aliasコマンドを使います。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dataich:~ dataich$ dotcloud <span style="color: #7a0874; font-weight: bold;">alias</span> add wordpress.www blog.dataich.com
Ok. Now please add the following DNS record:
blog.dataich.com. IN CNAME gateway.dotcloud.com.</pre></div></div>

<p>CNAMEでgateway.dotcloud.com.を設定するように言われるので、VALUE-DOMAIN側のドメイン設定を行います。</p>
<p>http://blog.dataich.com/</p>
<p>上記にアクセスし、動作確認。無事当ブログをdotCloudで動かすことに成功しました。<br />
ざっと確認したところ問題なし。これで暫く運用テストしてみます。</p>
<p>ここまでやっといてアレなのですが、そう負荷のない個人ブログを運用するにはちょっとお値段が辛いです。<br />
もう少しリーズナブルなプランがあればいいのですが。。</p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2011/08/02/wordpress-on-coreserver-to-dotcloud/&via=dataich&text=CORESERVERからdotCloudにWordpressをお引っ越し&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2011/08/02/wordpress-on-coreserver-to-dotcloud/_via=dataich_text=CORESERVER_dotCloud_Wordpress_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2011/08/02/wordpress-on-coreserver-to-dotcloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NAGASAKI-IT hands-on Spring 2011にてGitハンズオンやってきました</title>
		<link>http://blog.dataich.com/2011/05/28/git-handson-at-nagasaki-it-hands-on-spring-2011-report/</link>
		<comments>http://blog.dataich.com/2011/05/28/git-handson-at-nagasaki-it-hands-on-spring-2011-report/#comments</comments>
		<pubDate>Sat, 28 May 2011 03:39:07 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Diary]]></category>
		<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://blog.dataich.com/?p=1020</guid>
		<description><![CDATA[NAGASAKI-IT hands-on Spring 2011にてGitハンズオンやります エントリが遅くなってしまいました。久々人の前に立つということで少し緊張していましたが、おかげさまで無事に終了しました。今回は導 [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><a title="NAGASAKI-IT hands-on Spring 2011にてGitハンズオンやります" href="http://blog.dataich.com/2011/05/02/git-handson-at-nagasaki-it-hands-on-spring-2011/">NAGASAKI-IT hands-on Spring 2011にてGitハンズオンやります</a></p></blockquote>
<p>エントリが遅くなってしまいました。久々人の前に立つということで少し緊張していましたが、おかげさまで無事に終了しました。今回は導入編ということでPush、Pull等の操作は行わず、コミットまでの流れ、ブランチの切り方等をハンズオンしました。</p>
<p>準備していただいた皆様、ご参加くださった皆様ありがとうございました。飲み会も含め、とても楽しめた一日でした。</p>
<p>次回（2011/6/18に決まりました）はGitHubを使ってPush、Pull等の操作を含めたハンズオンにしようかと計画しておりますので、是非よろしくお願い致します。</p>
<div id="attachment_1028" class="wp-caption alignnone" style="width: 522px"><img class="size-medium wp-image-1028 " title="飲み会でリベンジを果たした@_ec7のプレゼン。フスマにもちゃんと写ったのがすごい。" src="http://blog.dataich.com/wp-content/uploads/写真-2011-05-21-19-22-31-512x382.jpg" alt="飲み会でリベンジを果たした@_ec7のプレゼン。フスマにもちゃんと写ったのがすごい。" width="512" height="382" /><p class="wp-caption-text">飲み会でリベンジを果たした@_ec7のプレゼン。フスマにもちゃんと写ったのがすごい。</p></div>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2011/05/28/git-handson-at-nagasaki-it-hands-on-spring-2011-report/&via=dataich&text=NAGASAKI-IT hands-on Spring 2011にてGitハンズオンやってきました&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2011/05/28/git-handson-at-nagasaki-it-hands-on-spring-2011-report/_via=dataich_text=NAGASAKI-IT_hands-on_Spring_2011_Git_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2011/05/28/git-handson-at-nagasaki-it-hands-on-spring-2011-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NAGASAKI-IT hands-on Spring 2011にてGitハンズオンやります</title>
		<link>http://blog.dataich.com/2011/05/02/git-handson-at-nagasaki-it-hands-on-spring-2011/</link>
		<comments>http://blog.dataich.com/2011/05/02/git-handson-at-nagasaki-it-hands-on-spring-2011/#comments</comments>
		<pubDate>Mon, 02 May 2011 14:45:29 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Diary]]></category>

		<guid isPermaLink="false">http://blog.dataich.com/?p=1015</guid>
		<description><![CDATA[NAGASAKI-IT hands-on Spring 2011ってのやります！ 5/21に長崎市立図書館にてNAGASAKI-IT hands-on Spring 2011というイベントが開催されます。詳細は上記を参考 [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><a href="http://reiare.net/blog/2011/05/02/nagasaki-it-hands-spring-2011/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/reiare.net/blog/2011/05/02/nagasaki-it-hands-spring-2011/?referer=');">NAGASAKI-IT hands-on Spring 2011ってのやります！</a><a href="http://reiare.net/blog/2011/05/02/nagasaki-it-hands-spring-2011/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/reiare.net/blog/2011/05/02/nagasaki-it-hands-spring-2011/?referer=');"> </a></p></blockquote>
<p>5/21に長崎市立図書館にてNAGASAKI-IT hands-on Spring 2011というイベントが開催されます。詳細は上記を参考にしていただきたいのですが、その中で「ひとりぎっと 〜ひとりで使うバージョン管理システム導入編〜」と称してGitのハンズオンをやらせていただくことになりました。</p>
<p>私自身Gitの分散バージョン管理としてのメリットをもろに受けるようなシチュエーションにあまり出くわさないのですが、分散バージョン管理としてではなくともメリットがたくさんあり、ひとりでの開発時にも手放せないものとなっています。Subversionくらいなら使ってるという方や、そもそもバージョン管理やったことないという方でも理解頂けるような導入的な内容にしています。</p>
<p><a href="http://atnd.org/events/15375" target="_blank" onclick="pageTracker._trackPageview('/outgoing/atnd.org/events/15375?referer=');">ATND</a>にて参加者様を募集してますので、興味のある方は是非ご参加ください。</p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2011/05/02/git-handson-at-nagasaki-it-hands-on-spring-2011/&via=dataich&text=NAGASAKI-IT hands-on Spring 2011にてGitハンズオンやります&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2011/05/02/git-handson-at-nagasaki-it-hands-on-spring-2011/_via=dataich_text=NAGASAKI-IT_hands-on_Spring_2011_Git_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2011/05/02/git-handson-at-nagasaki-it-hands-on-spring-2011/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MacアプリでURLをブラウザで開く方法</title>
		<link>http://blog.dataich.com/2011/05/01/open-url-with-browser-about-mac-app/</link>
		<comments>http://blog.dataich.com/2011/05/01/open-url-with-browser-about-mac-app/#comments</comments>
		<pubDate>Sun, 01 May 2011 14:28:26 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://blog.dataich.com/?p=1004</guid>
		<description><![CDATA[これでHTTPなURLスキームに対応しているアプリのidentifierの一覧が取れます。 ただ、このままだとブラウザでないアプリケーション（例えばEvernoteなど）も取れてしまいますので、うまい具合にブラウザだけ取 [...]]]></description>
			<content:encoded><![CDATA[<p>これでHTTPなURLスキームに対応しているアプリのidentifierの一覧が取れます。<br />
<script src="https://gist.github.com/950532.js?file=gistfile1.m"></script> </p>
<p>ただ、このままだとブラウザでないアプリケーション（例えばEvernoteなど）も取れてしまいますので、うまい具合にブラウザだけ取る方法があれば教えてください。</p>
<p> 次にURLをデフォルトブラウザで開く方法<br />
<script src="https://gist.github.com/950533.js?file=gistfile1.m"></script></p>
<p>最後にURLを指定のアプリケーションで開く方法<br />
<script src="https://gist.github.com/950534.js?file=gistfile1.m"></script></p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2011/05/01/open-url-with-browser-about-mac-app/&via=dataich&text=MacアプリでURLをブラウザで開く方法&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2011/05/01/open-url-with-browser-about-mac-app/_via=dataich_text=Mac_URL_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2011/05/01/open-url-with-browser-about-mac-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xcodeでリリースビルド時に.dmgを自動生成する</title>
		<link>http://blog.dataich.com/2011/05/01/create-dmg-image-after-built-on-xcode/</link>
		<comments>http://blog.dataich.com/2011/05/01/create-dmg-image-after-built-on-xcode/#comments</comments>
		<pubDate>Sun, 01 May 2011 13:55:25 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://blog.dataich.com/?p=997</guid>
		<description><![CDATA[Using Xcode to build a disk image (and upload a web site) こちらを参考に、hdiutilを使ってリリースビルド時のみ生成するようにしてみました。 グループとファイ [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><a href="http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/?referer=');">Using Xcode to build a disk image (and upload a web site)</a></p></blockquote>
<p>こちらを参考に、hdiutilを使ってリリースビルド時のみ生成するようにしてみました。</p>
<p>グループとファイルからビルドターゲットを右クリックし、[追加 &gt; 新規ビルドフェーズ &gt; 新規スクリプトを実行]を選択します。</p>
<p><a href="http://blog.dataich.com/wp-content/uploads/new-script.png" target="_blank" rel="lightbox[997]"><img class="alignnone size-medium wp-image-998" title="new-script" src="http://blog.dataich.com/wp-content/uploads/new-script-512x320.png" alt="" width="512" height="320" /></a></p>
<p>スクリプトを入力する画面が表示されますので、下記のようにスクリプトを設定します。.dmgはデスクに保存するようにしています。cpしているところは適時置き換えて頂ければいいかと思います。</p>
<p><script src="https://gist.github.com/950511.js?file=create_dmg.sh"></script></p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2011/05/01/create-dmg-image-after-built-on-xcode/&via=dataich&text=Xcodeでリリースビルド時に.dmgを自動生成する&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2011/05/01/create-dmg-image-after-built-on-xcode/_via=dataich_text=Xcode_.dmg_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2011/05/01/create-dmg-image-after-built-on-xcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

