<?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>Transrain &#187; php</title>
	<atom:link href="http://transrain.net/blog/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://transrain.net/blog</link>
	<description>悠希のだらだらメモ</description>
	<lastBuildDate>Wed, 01 Feb 2012 06:16:55 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://transrain.net/blog/?pushpress=hub'/>
		<item>
		<title>gitにpushしたwebサイトを自動的に同期させる</title>
		<link>http://transrain.net/blog/2011/04/05/211200</link>
		<comments>http://transrain.net/blog/2011/04/05/211200#comments</comments>
		<pubDate>Tue, 05 Apr 2011 12:12:00 +0000</pubDate>
		<dc:creator>yuki</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[開発]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hooks]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[サーバ]]></category>

		<guid isPermaLink="false">http://transrain.net/?p=115</guid>
		<description><![CDATA[earthquake_jpに関連して作業したので備考録としてメモ。 前提 gitのリモートリポジトリとHTTPサーバが同一のサーバに存在している状態です。 別サーバで行う場合はgit cloneを行う際にパス無し秘密鍵で &#8230; <a href="http://transrain.net/blog/2011/04/05/211200">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>earthquake_jpに関連して作業したので備考録としてメモ。</p>
<h2>前提</h2>
<p>gitのリモートリポジトリとHTTPサーバが同一のサーバに存在している状態です。</p>
<p>別サーバで行う場合は<code>git clone</code>を行う際にパス無し秘密鍵でcloneして<br />
おかないと上手く動作しないと思われます。</p>
<h2>処理の流れ</h2>
<p>開発者 → コミット → プッシュ → post-receive → Web API → git pull</p>
<h2>失敗</h2>
<ul>
<li>最初はpost-receiveでpullを発行しようとしたが、HTTPサーバとgitosisの権限が異なる。</li>
<li>sudoを発行してみたが、エラーが発生して処理が行えない。</li>
</ul>
<h2>結果</h2>
<ul>
<li>post-receiveはWeb APIへとアクセスする。</li>
<li>Web APIはHTTPサーバの権限で動作する。</li>
<li>Web APIではシェルスクリプトを実行する。</li>
<li>HTTPサーバの権限でpullが行われる。</li>
</ul>
<h2>例</h2>
<h3>リポジトリ.git/hooks/post-receive</h3>
<pre>#!/bin/sh
wget -q -O - http://APIのURL</pre>
<h3>API(update.php)</h3>
<pre>&lt;?php
$cmd = dirname(__FILE__) . '/update.sh';
$res = system($cmd);
if (false === $res) {
    echo "NGn";
} else {
    echo "OK:{$res}n";
}</pre>
<h3>シェルスクリプト(update.sh)</h3>
<pre>#!/bin/sh
cd /var/www/html/
/usr/bin/git --git-dir=/var/www/html/.git pull</pre>
<p>post-receive、update.shは実行権限を付加するのを忘れずに。update.phpはweb上から実行可能であれば問題ない。</p>
<p>念の為、127.0.0.1か自身のグローバルIPでのみアクセス可能にしている。</p>
]]></content:encoded>
			<wfw:commentRss>http://transrain.net/blog/2011/04/05/211200/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>実験中(autotestもどき+growl)</title>
		<link>http://transrain.net/blog/2011/02/09/220905</link>
		<comments>http://transrain.net/blog/2011/02/09/220905#comments</comments>
		<pubDate>Wed, 09 Feb 2011 13:09:05 +0000</pubDate>
		<dc:creator>yuki</dc:creator>
				<category><![CDATA[日記]]></category>
		<category><![CDATA[Autotest]]></category>
		<category><![CDATA[develop]]></category>
		<category><![CDATA[growl]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://transrain.net/?p=93</guid>
		<description><![CDATA[開発時にテスト結果がバンバン出るのがいいなとRuby界隈を見ていて思ったのでいろいろ実験。 実行したらGrowlに開始通知。 Phingでlintとユニットテストを走らせるように書いておく。 さっきのバッチファイルはph &#8230; <a href="http://transrain.net/blog/2011/02/09/220905">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>開発時にテスト結果がバンバン出るのがいいなとRuby界隈を見ていて思ったのでいろいろ実験。</p>
<p><a href="http://comicha.net/blog/wp-content/uploads/2011/02/autotest1.jpg"><img src="http://comicha.net/blog/wp-content/uploads/2011/02/autotest1-300x195.jpg" title="autotest1" width="300" height="195" class="alignnone size-medium wp-image-95" /></a><a href="http://comicha.net/blog/wp-content/uploads/2011/02/autotest2.jpg"><img src="http://comicha.net/blog/wp-content/uploads/2011/02/autotest2.jpg" title="autotest2" width="294" height="100" class="alignnone size-full wp-image-96" /></a></p>
<p>実行したらGrowlに開始通知。</p>
<p><a href="http://comicha.net/blog/wp-content/uploads/2011/02/autotest3.jpg"><img src="http://comicha.net/blog/wp-content/uploads/2011/02/autotest3-300x279.jpg" title="autotest3" width="300" height="279" class="alignnone size-medium wp-image-97" /></a></p>
<p>Phingでlintとユニットテストを走らせるように書いておく。<br />
さっきのバッチファイルはphingを実行するようにしてる。</p>
<p><a href="http://comicha.net/blog/wp-content/uploads/2011/02/autotest4.jpg"><img src="http://comicha.net/blog/wp-content/uploads/2011/02/autotest4-149x300.jpg" title="autotest4" width="149" height="300" class="size-medium wp-image-98 alignnone" /></a></p>
<p><a href="http://comicha.net/blog/wp-content/uploads/2011/02/autotest4.jpg"></a>監視対象のファイルを更新して保存すると裏でphingコマンドを実行して、テストとlintを実行している。<br />
そのログがGrowlに出力されている図。</p>
<p>ある程度まとまれば公開するつもりだけど、仕事が忙しくてリリース物作るほどの余裕がない罠。</p>
]]></content:encoded>
			<wfw:commentRss>http://transrain.net/blog/2011/02/09/220905/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

