<?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>cross HVN</title>
	<atom:link href="http://cross.hvn.to/?feed=rss2&#038;p=33" rel="self" type="application/rss+xml" />
	<link>http://cross.hvn.to</link>
	<description></description>
	<lastBuildDate>Fri, 29 Jun 2012 00:56:40 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>さくらのVPS設定[10]-SVNレポジトリの作成</title>
		<link>http://cross.hvn.to/?p=2058&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2581%2595%25e3%2581%258f%25e3%2582%2589%25e3%2581%25aevps%25e8%25a8%25ad%25e5%25ae%259a10-svn%25e3%2583%25ac%25e3%2583%259d%25e3%2582%25b8%25e3%2583%2588%25e3%2583%25aa%25e3%2581%25ae%25e4%25bd%259c%25e6%2588%2590</link>
		<comments>http://cross.hvn.to/?p=2058#comments</comments>
		<pubDate>Sun, 03 Jun 2012 06:45:52 +0000</pubDate>
		<dc:creator>sib</dc:creator>
				<category><![CDATA[VPS]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[さくらのVPS]]></category>

		<guid isPermaLink="false">http://cross.hvn.to/?p=2058</guid>
		<description><![CDATA[SVNをFTPのちょっと進化したくらいな気軽さで簡単に使えないかと設定しようとして思いの外はまってしまったので [...]]]></description>
			<content:encoded><![CDATA[<p>SVNをFTPのちょっと進化したくらいな気軽さで簡単に使えないかと設定しようとして思いの外はまってしまったのでメモをしておく。</p>
<p>主に参考にさせていただいたのは以下のサイトだ。<br />
<a href="http://d.hatena.ne.jp/ishikawa84g/20080915/1221424863" target="_blank">[Linux]10分で作る、Subversionレポジトリ (CentOS 版) </a><br />
<a href="http://www.nslabs.jp/subversion.rhtml" target="_blank">Subversion導入ツアー</a></p>
<p><span id="more-2058"></span><br />
<strong>ユーザーとレポジトリの作成</strong><br />
さくらのVPSで使われているCentOS6.2だとSVNそのものは最初から入っていたので、まずはSVNで使用するユーザー作成から行う。<a href="http://www.nslabs.jp/subversion.rhtml" target="_blank">Subversion導入ツアー</a>を参考に以下のようにした。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo useradd -M -r -s /sbin/nologin svnadmin
</pre>
<p>-Mはホームディレクトリ無し<br />
-rはシステムアカウントを生成<br />
-sはログインシェルの指定</p>
<p>次にレポジトリの作成をする。<br />
ディレクトリは/var/svn以下にしておいた。<br />
テストなのでtestrepoと名前を付けておき以下にSVNのお作法通りにtrunk,branches,tagsディレクトリを置いた。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo mkdir /var/svn
$ cd /var/svn
$ mkdir testrepo
$ sudo mkdir testrepo
$ sudo svnadmin create testrepo
$ sudo svn mkdir file:///var/svn/testrepo/{trunk,branches,tags} -m 'setup dir'
</pre>
<p><strong>xinetdのインストールと設定</strong><br />
サーバーはsvnserveをxinetd経由で動かすことにする。<br />
xinetdについてはコチラを参考にさせて頂いた。<br />
<a href="http://akibe.com/centos-setup-14-xinetd/" target="_blank">さくらのVPS CentOSでサーバ構築 14 – xinetd</a><br />
インストールと自動起動設定をする。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo yum install xinetd
$ /etc/init.d/xinetd start
xinetd を起動中: [  OK  ]
$ sudo chkconfig xinetd on
$ chkconfig --list xinetd
xinetd 	0:off	1:off	2:on	3:on	4:on	5:on	6:off
</pre>
<p>xinetd.dにsvnの設定をする。only_fromはあとで自宅のアドレスを調べて設定する。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo vi /etc/xinetd.d/svn
# default: off
# description: The svnserve server is a Subversion server.
service svn
{
        disable = no
        socket_type     = stream
        wait            = no
        user            = svnadmin
        server          = /usr/bin/svnserve
        server_args     = -i -r /var/svn
        log_on_failure  += USERID
        #only_from       = 192.168.24.0/24 127.0.0.1
}
</pre>
<p><strong>ファイヤーウォールの設定</strong><br />
svnserveは3690を使うのでポートを空ける。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo vi /etc/sysconfig/iptables
#この行を追加する。
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3690  -j ACCEPT
</pre>
<p>ファイヤーウォールを再起動し反映されているか確認する。</p>
<pre class="brush: xml; title: ; notranslate">
$ /etc/rc.d/init.d/iptables restart
$ iptables -L
</pre>
<p><strong>svnserveの設定</strong><br />
checkoutやcommitできるメンバーを限定したいので、svnserve.confを書き換える。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo vi /var/svn/testrepo/conf/svnserve.conf
anon-access = none
auth-access = write
password-db = passwd
</pre>
<p>続いてpasswdを編集してログインできるユーザを限定する。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo vi /var/svn/testrepo/conf/passwd
  harry = harryssecret
</pre>
<p>次にレポジトリの所有者を変更する。これを変更しておかないとcommitの時に警告が出てくる。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo chown -R svnadmin /var/svn/testrepo
</pre>
<p>以上で、SVNクライアントから接続しCheckoutしたりCommitしたりできるようになる。</p>
]]></content:encoded>
			<wfw:commentRss>http://cross.hvn.to/?feed=rss2&#038;p=2058</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>「インタラクションデザインの教科書」Dan Saffer</title>
		<link>http://cross.hvn.to/?p=1962&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2580%258c%25e3%2582%25a4%25e3%2583%25b3%25e3%2582%25bf%25e3%2583%25a9%25e3%2582%25af%25e3%2582%25b7%25e3%2583%25a7%25e3%2583%25b3%25e3%2583%2587%25e3%2582%25b6%25e3%2582%25a4%25e3%2583%25b3%25e3%2581%25ae%25e6%2595%2599%25e7%25a7%2591%25e6%259b%25b8%25e3%2580%258ddan-saffer</link>
		<comments>http://cross.hvn.to/?p=1962#comments</comments>
		<pubDate>Tue, 29 May 2012 02:14:24 +0000</pubDate>
		<dc:creator>sib</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[読書記録]]></category>
		<category><![CDATA[IxD]]></category>
		<category><![CDATA[インタラクションデザイン]]></category>

		<guid isPermaLink="false">http://cross.hvn.to/?p=1962</guid>
		<description><![CDATA[この「インタラクションデザインの教科書 (DESIGN IT! BOOKS)」原著の題だと「Designing [...]]]></description>
			<content:encoded><![CDATA[<p>この「<a href="http://www.amazon.co.jp/gp/product/4839922381/ref=as_li_ss_tl?ie=UTF8&#038;tag=sibsib-22&#038;linkCode=as2&#038;camp=247&#038;creative=7399&#038;creativeASIN=4839922381">インタラクションデザインの教科書 (DESIGN IT! BOOKS)</a><img src="http://www.assoc-amazon.jp/e/ir?t=sibsib-22&#038;l=as2&#038;o=9&#038;a=4839922381" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />」原著の題だと「<a href="http://www.amazon.co.jp/gp/product/0321643399/ref=as_li_ss_tl?ie=UTF8&#038;tag=sibsib-22&#038;linkCode=as2&#038;camp=247&#038;creative=7399&#038;creativeASIN=0321643399">Designing for Interaction: Creating Innovative Applications and Devices (Voices That Matter)</a><img src="http://www.assoc-amazon.jp/e/ir?t=sibsib-22&#038;l=as2&#038;o=9&#038;a=0321643399" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> 」は、著者のDan Safferがカーネギーメロン大学で大学院生としてインタラクションデザインの講義を担当する際に生徒に読ませるのに良い本を見つけるのに苦労をしたことを発端としている。そのせいか、同じような分野を扱っている「<a href="http://www.amazon.co.jp/gp/product/4048672452/ref=as_li_ss_tl?ie=UTF8&#038;tag=sibsib-22&#038;linkCode=as2&#038;camp=247&#038;creative=7399&#038;creativeASIN=4048672452">About Face 3 インタラクションデザインの極意</a><img src="http://www.assoc-amazon.jp/e/ir?t=sibsib-22&#038;l=as2&#038;o=9&#038;a=4048672452" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />」と比べるとザックリと細部を落とし見通しがつけやすい構成になっている。この本はまだ新しいこの領域の現在進行中にある中で、どのようになっているのか、そしてどのような手法の組み合わせを検討すべきかについて参考になった。</p>
<p><span id="more-1962"></span></p>
<p>インタラクションデザインの定義をこの本より引っ張ってくると、このようになる。</p>
<blockquote><p>
　インタラクションデザインは、製品やサービスを介して人と人がインタラクション（対話）することを手助けするための技術である。そしてまた、範囲を限定していえば、何らかの「認識力」を持つ製品と人間とのインタラクションに関するものであるといえる。認識力を持つ製品とは、人間に対して何らかの判断を行い、反応を返すことができるマイクロプロセッサを伴う製品のことである。
</p></blockquote>
<p>なんとなくで認識をしていた部分について、改めてこのように定義された文章を読むのは頭の整理ができて良い。<br />
更に前半に書かれていた「近接領域」と「4つのアプローチ」が参考になったので、少しメモをしておく。</p>
<p><strong>近接領域</strong><br />
インタラクションデザインについての文献は少ない状態なので、今後調べたり学習したりするにあたって、近接領域として何が存在するのかをまとめてくれている部分は、とても役に立ちそうだ。<br />
ざっとその関係を記述すると、</p>
<ul>
<li>UX（ユーザーエクスペリエンスデザイン）<br />
ユーザーと製品やサービスとの出会いを、ビジュアル・インタラクション・音声などのデザインから見て調和を図る。<br />
インタラクションデザインのほぼ全てを含みそれよりも広い領域を扱う。<br />
同じくUXに含まれインタラクションデザインと一部分の重なる分野に下記がある。</li>
<ul>
<li>IA(情報アーキテクチャ)<br />
ユーザーの欲しい情報が見つかるようなコンテンツの構造とラベル付など、コンテンツ構造そのもの。</li>
<li>CD(コミュニケーションデザイン)、もしくはグラフィックデザイン<br />
フォント、色、レイアウトなどコンテンツを伝えるための視覚的な言語。</li>
<li>UIE(ユーザインターフェース工学)<br />
デジタルカメラの画面など、デジタル機器の制御。
</li>
</ul>
<li>HCI(ヒューマン・コンピュータ・インタラクション)<br />
インタラクションデザインよりも、もっと定量的な方法論に基づく。<br />
OSなど人間がいかにコンピューターと関係しているかについての分野。
</li>
<ul>
<li>UE(ユーザビリティ工学)<br />
製品をユーザーにとって分かりやすいものにするためのテスティングに関する分野。
</li>
</ul>
<li>HF(ヒューマンファクター)<br />
物が人間の身体的・心理的制約に従うようにする。</p>
</li>
<li>ID(工業デザイン)<br />
形に関するもの。使用目的と機能に合わせて物の形を決める。</li>
</ul>
<p>インタラクションデザインの文献だけで足りない時や深掘りしたい時は、これらの近接のどの領域あたりに検討をつけて探れば良いのかが見えやすくなった。</p>
<p><strong>4つのアプローチ</strong><br />
インタラクションデザインは4つのアプローチとその組み合わせにより課題の解決を図るとしている。</p>
<ul>
<li>ユーザー中心デザイン(UCD:User-Centered Design)<br />
「ユーザーはなんでも知っている」と言うことをデザインの哲学とする。<br />
ユーザーがゴールを達成するためにデザイナーが関わる。<br />
デザインプロセスの全段階で、ユーザーが参加することが理想。</p>
</li>
<li>アクティビティ中心デザイン(Activity-Centered Design)<br />
目的のために行われる行為や判断のかたまりをアクティビティと定義し焦点を当てる方法。<br />
アクティビティは行為と判断から成り立つタスクの連続。<br />
ユーザーゴールのためではなくユーザーのタスク完了のための解決策をデザインする。</p>
</li>
<li>システムデザイン(System Design)<br />
規定のコンポーネントの組み合わせでデザインの解決策を作る。<br />
相互作用するコンポーネントであるシステムがデザインプロセスの中心。<br />
ゴール、センサ、比較器、差動装置といったコンポーネントがシステムに含まれ、このコンポーネントをデザインする。</p>
</li>
<li>才能に基づくデザイン(Genius Design)<br />
デザイナーの勘と経験に頼るアプローチ。<br />
Apple社のようにセキュリティ上の理由からユーザーを巻き込む調査を行わないような場合やユーザーを絡ませるような資金や時間のない場合にとられるアプローチ。<br />
デザイナー自身の感性が反映されやすい。</p>
</li>
</ul>
<p>私の場合は、ほぼ「才能に基づくデザイン」がメインでアクティビティがほんの少しふりかけのように混じっているくらいのアプローチとなっている。<br />
しかし今後は手持ち武器を増やすためにも他のアプローチを調べ、まずは個人開発の物から適用していってみたい。できればデザインリサーチも行なってみたいのだけど、その機会をどのようにしたら作れるか少し検討してみることにした。</p>
<p>この本ではさらにインタラクションデザインの基礎要素や法則などが説明されている。この辺りについてはスタディを書きつつ、ひとつひとつ深めていってみようかと考えている。<br />
そうしたものや、スケッチ、ワイヤーなどのデザインドキュメント、インターフェイスあたりも説明されているが、中でも後半部分の、サービスデザインやウェアラブル・ユビキタスに触れている部分の未来に関する部分は、この本の中でも少し扱いが違い、インタラクションデザインが持つ可能性に楽しみを感じさせてくれた。</p>
<p><iframe src="http://rcm-jp.amazon.co.jp/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=sibsib-22&#038;o=9&#038;p=8&#038;l=as4&#038;m=amazon&#038;f=ifr&#038;ref=ss_til&#038;asins=4839922381" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://cross.hvn.to/?feed=rss2&#038;p=1962</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>「虐殺器官」伊藤計劃</title>
		<link>http://cross.hvn.to/?p=1922&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2580%258c%25e8%2599%2590%25e6%25ae%25ba%25e5%2599%25a8%25e5%25ae%2598%25e3%2580%258d%25e4%25bc%258a%25e8%2597%25a4%25e8%25a8%2588%25e5%258a%2583</link>
		<comments>http://cross.hvn.to/?p=1922#comments</comments>
		<pubDate>Mon, 28 May 2012 07:00:35 +0000</pubDate>
		<dc:creator>sib</dc:creator>
				<category><![CDATA[読書記録]]></category>
		<category><![CDATA[AR]]></category>
		<category><![CDATA[小説]]></category>

		<guid isPermaLink="false">http://cross.hvn.to/?p=1922</guid>
		<description><![CDATA[伊藤計劃の書いた「虐殺器官」を読んだ。おおよそのあらすじは、以下のようになる。 911ではじまったテロとの戦い [...]]]></description>
			<content:encoded><![CDATA[<p>伊藤計劃の書いた「<a href="http://www.amazon.co.jp/gp/product/4150309841/ref=as_li_ss_tl?ie=UTF8&#038;tag=sibsib-22&#038;linkCode=as2&#038;camp=247&#038;creative=7399&#038;creativeASIN=4150309841">虐殺器官</a><img src="http://www.assoc-amazon.jp/e/ir?t=sibsib-22&#038;l=as2&#038;o=9&#038;a=4150309841" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />」を読んだ。おおよそのあらすじは、以下のようになる。</p>
<p>911ではじまったテロとの戦いが続いている近未来が舞台となる。その頃、アメリカの軍隊は、陸軍（アーミー）、空軍（エアフォース）、海軍（ネイビー）、海兵隊（マリーンズ）、情報軍（インフォメーションズ）から構成されており、主人公の”ぼく”グラウヴィス・シェパードは、情報軍・特殊検索軍i分遣隊で大尉として従軍している。この部隊はアメリカ5軍の中でも暗殺を請け負う唯一の部隊であり、主人公も世界各地の紛争地帯で暗殺を遂行している。<br />
そして、その世界では、ここ数年後進国での虐殺が増えてきている。その虐殺地帯に現れ暗殺対象になり、幾度も失敗し続けているジョン・ポールという人物が居る。この物語は、ウヴィス・シェパードが、その目標であるジョン・ポールをプラハやインドなど世界各地で追いかけていく話であり、その過程で虐殺の動悸や方法が明らかになっていく構成となっている。</p>
<p><span id="more-1922"></span></p>
<p>著者の伊藤計劃は2009年に満34歳で逝去している。彼が小説家として活躍したのは、その早すぎる人生の最後の三年間であり、この「虐殺器官」は初めて出版された近未来SF長編小説となる。</p>
<p>凄惨な虐殺の描写をするイントロダクションと共に、それを成り立たせていた虐殺の文法と、ジョン・ポールを捕らえところで終りとせずに、エピローグ配されたアメリカ-世界の反転に至る構成に心を奪われた。<br />
話の中心部になる虐殺の文法を組み立てる深層言語とクレオール語や脳機能にまつわるエピソードが、グラウヴィス・シェパードが殺意でさえも自分のものではないと感じる様、そして民間軍事請負業者の戦争を普通の仕事と同じようにプレゼンする態度と現場で起きている穴だらけにされた死体や家族と離れ離れになった子供の存在する現実との乖離などと相まって、自分の存在はそんなに自分ではないのだろうという気分にさせられる。</p>
<p>この小説は、様々な世界の問題（貧困や対立、そしてテロ）とテクノロジーを繊細に組み立てることで世界観を作り上げている。そうした世界観を作り上げている小道具の中で、オルタナ（副現実）という名称で（たぶんARの進化した姿なのだろう）現実にレイヤードされて視覚に情報が映し出される描写が未来の都市や建築の姿を想像させられた。<br />
このオルタナは、もちろん戦場でも使われているが、それよりもプラハにおける第二次世界大戦の爆撃を免れた古都の姿とレイヤーされる大量の情報という対比が気になった。オルタナのプラハは「リドリー・スコットの創造したロスアンゼルス」= たぶんブレードランナーの冒頭のようであったと書く。<br />
また病院でオルタナを見るためのデバイスを忘れてきた描写があり、その場では床に現れるマーカーで誘導を行なっていた。病院は複雑すぎて迷路のようであり、マーカーがないと迷っていたであろうと書いている。<br />
そうしたブレードランナーの未来がオルタナの中にやってきたプラハの姿や、複雑な病院などから示唆されて、未来の都市や建築というのは、サインや広告の多くが撤退し、建物や街自体が入り組んだ姿をしているのかもしれないと想像をしてみた。つまりそれは建築が遅いメディアとしてのスピードを発揮できるような世界であり、広告のような速いスピードのメディアを必要とするものに合わせる必要がなくなり、また空間の心地よさではなく経路のわかりやすさを目指した動線計画などからの脱却が起きた姿かもしれない。もしもこの妄想通りであれば、これからの都市や建物は伽藍のようになるかバザールのようになるか分からないが、より空間的な豊かさを目指すようになるだろうし、その豊かさはARの発展形（オルタナ的な）を空間の余白として組み込めるような形へと変化していくのだろう。こうなっていくと未来の都市/建築は、案外とそのメディアとしての遅さにみあったどっしりとした空間経験を与えてくれるものになってくれるかもしれない。</p>
<p>以上「<a href="http://www.amazon.co.jp/gp/product/4150309841/ref=as_li_ss_tl?ie=UTF8&#038;tag=sibsib-22&#038;linkCode=as2&#038;camp=247&#038;creative=7399&#038;creativeASIN=4150309841">虐殺器官</a><img src="http://www.assoc-amazon.jp/e/ir?t=sibsib-22&#038;l=as2&#038;o=9&#038;a=4150309841" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />」を読んだ感想とそこから発生した妄想を書いてみた。</p>
<p><iframe src="http://rcm-jp.amazon.co.jp/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=sibsib-22&#038;o=9&#038;p=8&#038;l=as4&#038;m=amazon&#038;f=ifr&#038;ref=ss_til&#038;asins=4150309841" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://cross.hvn.to/?feed=rss2&#038;p=1922</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>さくらのVPS設定[9]-NginxでPHP-FPMを使う。</title>
		<link>http://cross.hvn.to/?p=1874&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2581%2595%25e3%2581%258f%25e3%2582%2589%25e3%2581%25aevps%25e8%25a8%25ad%25e5%25ae%259a9-nginx%25e3%2581%25a7php-fpm%25e3%2582%2592%25e4%25bd%25bf%25e3%2581%2586%25e3%2580%2582</link>
		<comments>http://cross.hvn.to/?p=1874#comments</comments>
		<pubDate>Mon, 21 May 2012 05:21:09 +0000</pubDate>
		<dc:creator>sib</dc:creator>
				<category><![CDATA[Nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[yum]]></category>
		<category><![CDATA[さくらのVPS]]></category>

		<guid isPermaLink="false">http://cross.hvn.to/?p=1874</guid>
		<description><![CDATA[NginxでPHPを使おうとした場合、別プロセスで動くPHPとFastCGIでのソケット経由でやり取りを行うこ [...]]]></description>
			<content:encoded><![CDATA[<p>NginxでPHPを使おうとした場合、別プロセスで動くPHPとFastCGIでのソケット経由でやり取りを行うことになる。これを管理するモジュールの一つにPHP-FPMというものがあり、今回はそれを使用することにする。</p>
<p>こちらのサイトにもPHP-FPMの詳しい説明が書かれてありとても参考になった。<br />
<a href="http://sakura.off-soft.net/centos/apache-nginx-2-php-fpm-install.html" target="_blank">apache のかわりにnginxを使ってみる(2) php-fpmをインストールする</a></p>
<p>PHPそのものもインストールされていないので、そちらのインストールも説明していく。<br />
PHPは5.3.3まではパッチを当てる必要がある。それ以降であればPHP-FPMが予め組み込まれておりパッチを当てる必要は無い。そのため、レポジトリ登録したら一度確認をしてからインストール作業に入る。</p>
<p><span id="more-1874"></span></p>
<p><strong>PHPとPHP-FPMのインストール</strong></p>
<p>今回のインストールでは、こちらのサイトを基本として参考にさせて頂いた。<br />
<a href="http://se-suganuma.blogspot.jp/2012/04/centosnginx-php-fpminstallwordpress.html" target="_blank">CentOSにNginx + php-fpmをInstall、設定してWordPressを動かす</a></p>
<p>ただし、上記サイトではCentOS 5.8 32bitであり、契約した環境はCentOS6.2 64bitなため下記が違う。<br />
・remiのレポジトリはcentOS6版を入れる。5までとは違う。<br />
・epelリポジトリはcentOS6ではインストール済みなので、入れる必要はない。</p>
<p>標準のリポジトリにはphp-fpmがないため、<a href="http://rpms.famillecollet.com/" target="_blank">REMIレポジトリ</a>を追加する。</p>
<pre class="brush: xml; title: ; notranslate">
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -ivh remi-release-6.rpm
</pre>
<p>yumを確認するとphp-fpmも存在し、PHPは5.3.13なのでパッチを当てる必要はないようだ。</p>
<pre class="brush: xml; title: ; notranslate">
# yum list --enablerepo=remi | grep php
php.x86_64       5.3.13-1.el6.remi   remi  
・・・
php-fpm.x86_64   5.3.13-1.el6.remi   remi 
・・・
</pre>
<p>インストールするPHPと関連ライブラリは以下にしておいた。<br />
php ;本体<br />
php-fpm ;PHP FastCGI Process Manager FastCGIを動かすためのライブラリ<br />
php-devel ;PHP拡張用のライブラリ<br />
php-cli ;コマンドラインでPHPを使えるようにする<br />
php-xml ;PHPでXMLを取り扱うライブラリ<br />
php-mbstring ;マルチバイト言語を扱うためのライブラリ<br />
php-gd ;PHP用グラフィックライブラリ</p>
<p>ライブラリ情報はyum infoで調べることができる。</p>
<pre class="brush: xml; title: ; notranslate">
# yum info php-xml  --enablerepo=remi
</pre>
<p>インストールする。</p>
<pre class="brush: xml; title: ; notranslate">
# yum install php php-fpm php-devel php-cli php-xml  php-mbstring php-gd --enablerepo=remi
・・・
Installed:
  php.x86_64 0:5.3.13-1.el6.remi            php-cli.x86_64 0:5.3.13-1.el6.remi        php-devel.x86_64 0:5.3.13-1.el6.remi          
  php-fpm.x86_64 0:5.3.13-1.el6.remi        php-gd.x86_64 0:5.3.13-1.el6.remi         php-mbstring.x86_64 0:5.3.13-1.el6.remi       
  php-xml.x86_64 0:5.3.13-1.el6.remi       

Dependency Installed:
  apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1    httpd.x86_64 0:2.2.15-15.el6.centos.1    httpd-tools.x86_64 0:2.2.15-15.el6.centos.1   
  libXpm.x86_64 0:3.5.8-2.el6               libxslt.x86_64 0:1.1.26-2.el6            php-common.x86_64 0:5.3.13-1.el6.remi         
  t1lib.x86_64 0:5.1.2-6.el6_2.1           

Complete!

# php -v
PHP 5.3.13 (cli) (built: May  9 2012 16:43:49) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

</pre>
<p>インストールして、ディレクトリチェックしていたら、なんか馴染んだものがvar/wwwに入ってしまってる。<br />
ログを良く見ると、httpdがインストールされてしまっていた。<br />
ということで、var/www/に入っていたnginx扱いのデータはvar/webdev/へと移動することにした。</p>
<p><strong>php-fpmとnginxの設定</strong></p>
<p>/etc/php-fpm.confはそのままで変更なし。</p>
<p>/etc/php-fpm.d/www.confでポートの確認(9000)をし、userとgroupをnginxへ変更する。</p>
<pre class="brush: xml; title: ; notranslate">
#vi /etc/php-fpm.d/www.conf
・・・・
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000
・・・・
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
</pre>
<p>引き続き、nginx.confを変更しphpが使えるようにする。<br />
大半はコメントアウトされていたのを消すことで大丈夫なようだ。</p>
<pre class="brush: xml; title: ; notranslate">
# 念の為にphpディレクトリを作成しbasic認証をかけテストゾーンにした。
location = /php/index.php {
    alias 		/var/webdev/php/;
    auth_basic    	&quot;PHP test&quot;;
    auth_basic_user_file    &quot;/var/webdev/php/.htpasswd&quot;;
    fastcgi_pass   	127.0.0.1:9000;
    fastcgi_index  	index.php;
    fastcgi_param  	SCRIPT_FILENAME /var/webdev/$fastcgi_script_name;
    include		fastcgi_params;

}

# rootはserverと同じなので設定せず。SCRIPT_FILENAMEのパス変更。
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ /*\.php$ {
#   root   		/var/webdev/index/html;
    fastcgi_pass   	127.0.0.1:9000;
    fastcgi_index  	index.php;
#   fastcgi_param       SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    fastcgi_param  	SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include		fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
    deny  	all;
}
</pre>
<p>phpディレクトリを作成し、パスワードを暗号化して.htpasswdにいれる。</p>
<pre class="brush: xml; title: ; notranslate">
# mkdir /var/webdev/php
# cd /var/webdev/php
# vi .htpasswd
</pre>
<p>php-fpmを起動し、nginxを再起動する。</p>
<pre class="brush: xml; title: ; notranslate">
# /etc/rc.d/init.d/php-fpm start
# /etc/init.d/nginx restart
</pre>
<p>phpinfoを出力してみる。</p>
<pre class="brush: xml; title: ; notranslate">
# echo '&lt;?php echo phpinfo(); ?&gt;' &gt; index.php
</pre>
<p>ブラウザで確認して大丈夫だったら、php-fpmの自動起動設定をする。</p>
<pre class="brush: xml; title: ; notranslate">
# chkconfig php-fpm on
# chkconfig --list php-fpm
</pre>
<p>これでphpがnginxでも使えるようになった。<br />
もしもサブドメイン使用するアプリ作成した場合は、アプリにより設定が変わる可能性があるので、projectsディレクトリ以下にあるアプリごとのconfへphpの設定を書くことにした。</p>
<p>wordpressについては気が向いたらいつか行う事にして、ここまででとりあえずVPS設定は終わりとする。<br />
また環境設定ができたため、これから作成するスタディにはできるだけリアルタイム処理を加え、様々なパターン検証を行うことにした。</p>
]]></content:encoded>
			<wfw:commentRss>http://cross.hvn.to/?feed=rss2&#038;p=1874</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>さくらのVPS設定[8]-NginxでリバースプロキシとNodeアプリ</title>
		<link>http://cross.hvn.to/?p=1838&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2581%2595%25e3%2581%258f%25e3%2582%2589%25e3%2581%25aevps%25e8%25a8%25ad%25e5%25ae%259a8-nginx%25e3%2581%25a7%25e3%2583%25aa%25e3%2583%2590%25e3%2583%25bc%25e3%2582%25b9%25e3%2583%2597%25e3%2583%25ad%25e3%2582%25ad%25e3%2582%25b7%25e3%2581%25a8node%25e3%2582%25a2%25e3%2583%2597%25e3%2583%25aa</link>
		<comments>http://cross.hvn.to/?p=1838#comments</comments>
		<pubDate>Sat, 19 May 2012 04:50:30 +0000</pubDate>
		<dc:creator>sib</dc:creator>
				<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[さくらのVPS]]></category>

		<guid isPermaLink="false">http://cross.hvn.to/?p=1838</guid>
		<description><![CDATA[リバースプロキシは、アクセスを代行して受け取るサーバーだ。wikipediaから引用すると、以下のような説明に [...]]]></description>
			<content:encoded><![CDATA[<p>リバースプロキシは、アクセスを代行して受け取るサーバーだ。wikipediaから引用すると、以下のような説明になる。</p>
<blockquote><p><a href="http://ja.wikipedia.org/wiki/%E3%83%AA%E3%83%90%E3%83%BC%E3%82%B9%E3%83%97%E3%83%AD%E3%82%AD%E3%82%B7" target="_blank">リバースプロキシ</a><br />
リバースプロキシ（英: Reverse proxy）または逆プロキシは、特定のサーバへの要求を必ず経由するように設置されたプロキシサーバ。一般的なプロキシとは異なり不特定多数のサーバを対象としない。リバースプロキシは、不特定多数のクライアントから寄せられる要求に対して、応答を肩代わりすることにより特定のサーバの負担を軽減したり、アクセスを制限することにより特定のサーバのセキュリティを高めたりする目的に用いられる。
</p></blockquote>
<p>node.jsでアプリを作成しforeverで永続化した場合、xxx.xxx.xx:3000などと最後にポート番号がついてしまう、これがとても気になっており、nginxでリバースプロクシを入れてアプリごとサブドメイン運用をしようとしたきっかけとなった。もちろんサブディレクトリの方にも入れることができるので簡単な実験とかはそちらの方がいいのかもしれない。<br />
またnodeには動的な物を任せ、静的な部分についてはnginxで取り扱う形のほうがパフォーマンスから見ても良いようだ。<br />
それとリバースプロクシはwebsocketを通さないのでnginx_tcp_proxy_moduleを使用して動かす方法も書いておく。</p>
<p><span id="more-1838"></span></p>
<p>使用しているのは、以前作った<a href="http://cross.hvn.to/?p=1461" target="_blank">タッチ共有アプリ</a>だ。これをさくらのVPSサーバーへ持ってきて諸処の作業を行った。</p>
<p><strong>nginx_tcp_proxy_moduleでnode.jsのsocket.ioをリバースプロクシさせる</strong></p>
<p>nginx_tcp_proxy_moduleのインストールは以前の<a href="http://cross.hvn.to/?p=1694" target="_blank">エントリ</a>の通りだ。そして設定方法は次のブログ記事を参考にさせて頂いた。</p>
<p><a href="http://d.hatena.ne.jp/shim0mura/20120118/1326916953" target="_blank">nginxでsocket.ioのリバースプロキシ設定</a><br />
<a href="http://d.hatena.ne.jp/hadashia/20110822/1314017835" target="_blank">nginx_tcp_proxy_module を入れてnode.jsのsocket.ioを動かすnginxの設定</a></p>
<p>モジュール設定はtcpブロックで行うがhttpブロックとたいして変わりがない。<br />
そして/usr/local/nginx/conf/tcps以下にtcp設定を置きnginx.confからincludeする形にした。</p>
<pre class="brush: xml; title: ; notranslate">
user nginx;
worker_processes  2;
・・・・
events {
    worker_connections  1024;
}
# Load config files from th/usr/local/nginx/conf/tcps/ directory
include tcps/*.conf;

http {
　・・・・
}
</pre>
<p>includeしたtcp_cotouch.confはこのような内容であり、3000ポートでnodeアプリを動かし、サイトに3001で接続するとちゃんと動くのを確認できた。</p>
<pre class="brush: xml; title: ; notranslate">
tcp {
  upstream coTouchApp {
    server 127.0.0.1:3000;
    check interval=3000 rise=2 fall=5 timeout=1000;
  }

  server {
    listen 3001;
    server_name cotouch.omusuhi.info;

    proxy_read_timeout 200000;
    proxy_send_timeout 200000;
    proxy_pass coTouchApp;
  }
}
</pre>
<p>ところで、ソケット通信は、こちらの説明でも書いてある通り、IPアドレスとPort番号を一組とした通信手段となる。<br />
<a href="http://www.7key.jp/nw/technology/term/basic/socket.html" target="_blank">ソケット【socket】　</a></p>
<blockquote><p>「ソケット」というのはIPアドレスとPort番号を一組にしたものに結び付けられた仮想メモリ空間なのです。 相手にデータを送るときは、このメモリ空間に通信するためのデータを書き込むことによって 「Socket」ライブラリの中の「socket」プログラムが相手アプリケーションとデータの通信を行ってくれるのです。</p></blockquote>
<p>なので、[[Portが一つ占有されることになる]]はずだと思いながら、tcpとhttpで同じポート番号を指定すると、動いてしまった。しかしながら、別々のポートを指定していた時とは違い引っかかりがある。どういうことなのだろうと思いnginxを停めてinit.dで再起動しようとするとポートが使われていて動かせないと出てくる。</p>
<pre class="brush: xml; title: ; notranslate">
sudo /etc/init.d/nginx restart
</pre>
<p>前の時は、設定ファイルのリロードだったのを思い出し、nginx.confでtcpとhttpのポート指定を書き換えた上でnginxを機動、tcpとhttpのポート指定を同じにした上で下記のコマンドで設定リロードする。</p>
<pre class="brush: xml; title: ; notranslate">
sudo nginx -s reload
</pre>
<p>そうすると同じポートで動いてしまった。ここで、エラーログを確認しようとした。</p>
<pre class="brush: xml; title: ; notranslate">
sudo vi /usr/local/nginx/logs/error.log
</pre>
<p>すると重くて開くのにとんでもなく時間が掛かる。<br />
やはり、ソケットとhttpの接続とで混乱が起きていた模様で大量のエラーが発生していた。これで同じポート指定はやはり出来ないことが分かった。<br />
そして念の為にtcpブロックで同じポート指定で2つ動かそうとしてみたら、先に書かれていたものが優先され、default_serverの指定が後のサーバにあった場合、既に使われているというエラーが出る。<br />
このため、やはりtcpのserverブロックは1ポート専有というのを再確認することができた。</p>
<p><strong>nodeアプリをhttpブロックでリバースプロキシ</strong></p>
<p>soket.ioでの接続は現段階ではリバースプロキシしてもあまり意味が無いので、これまでのようにポート指定で行うことにして、ソケットとは関係のないnodeアプリ本体の部分にリバースプロキシを使いURLにポート番号が出ないようにすることにした。<br />
soket.ioと本体のポート番号を変えるのは下記の記事を参考にさせていただいている。<br />
<a href="http://stackoverflow.com/questions/10324864/socket-io-chat-on-dreamhost-hiding-the-url" target="_blank">Socket.io Chat on Dreamhost: Hiding the URL</a></p>
<p>nodeアプリでは、このように本体を3001、ソケットを3002として指定しなおしている。</p>
<pre class="brush: xml; title: ; notranslate">
var sys = require('util'),
		express = require('express'),
		app = express.createServer();

app.configure(function(){
	app.use(express.static(__dirname+'/views'));
});
app.listen(3001);
//var io = require('socket.io').listen(app);appではなくポート番号指定と変えている。
var io = require('socket.io').listen(3002);

io.sockets.on('connection', function(socket){
・・・・

</pre>
<p>html部分だと、index.htmlでsocket.io.jsを指定する部分をポート番号付きに変更する。</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!--&lt;script src=&quot;/socket.io/socket.io.js&quot;&gt;&lt;/script&gt; --&gt;
&lt;script src=&quot;http://www.omusuhi.info:3002/socket.io/socket.io.js&quot;&gt;&lt;/script&gt;
</pre>
<p>socketを使うクライアント側jsファイルの方でもsocket.io側のポート指定へと変える。</p>
<pre class="brush: xml; title: ; notranslate">
function initSocket(){
  var socket = io.connect('http://www.omusuhi.info:3002/');
  socket.on('message', function(t){
    console.log('mes; '+t);
  });
・・・・
}
</pre>
<p>Nodeアプリの変更点は以上となる。次にnginxでリバースプロキシの設定を行った。<br />
参考にさせていただいたのは、主にこちらのサイトだ。<br />
<a href="http://hartlessbydesign.com/blog/view/206-virtualmin-apache-and-nginx-reverse-proxy.html" target="_blank">Virtualmin, Apache, and Nginx Reverse Proxy</a><br />
<a href="http://totekan.jp/server/sakura-vps-settings-wordpress-nginx-reverse-proxy/" target="_blank">さくらVPS を設定してみる:Nginx + リバースプロキシで WordPress を動かしてみた♪</a><br />
<a href="http://sakura.off-soft.net/centos/apache-nginx-10-proxy.html" target="_blank">apache のかわりにnginxを使ってみる(10) nginx をリバースプロキシとして使ってみた</a><br />
<a href="http://d.hatena.ne.jp/mkouhei/20100121/1264086004" target="_blank">nginxでリバースプロキシ。</a></p>
<p>プロキシ共有設定ファイルを上記サイトを見つつ、このような感じで書き、<br />
projects/proxy.confへと保存した。</p>
<pre class="brush: xml; title: ; notranslate">
proxy_cache_path        /var/cache/nginx/ levels=1:2 keys_zone=czone:10m max_size=100m inactive=120m;
proxy_temp_path         /var/cache/nginx;
proxy_redirect          off;
proxy_set_header        Host            $host;
proxy_set_header        X-Real-IP       $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size    10m;
client_body_buffer_size 128k;
proxy_connect_timeout   90;
proxy_send_timeout      90;
proxy_read_timeout      90;
proxy_buffers           32 4k;
proxy_cache_valid       200 302 10m;
proxy_cache_valid       301 1h;                                                           
proxy_cache_valid       any 1m;
</pre>
<p>また、今回のアプリのプロキシ設定を下記のように書き、<br />
projects/cotouch.confへと保存してある。</p>
<pre class="brush: xml; title: ; notranslate">
upstream cotouch {
    ip_hash;
    server 127.0.0.1:3001;
}

server {
    listen   80;
    server_name cotouch.omusuhi.info;
    location / {
        proxy_pass http://cotouch/;
    }
}
</pre>
<p>前回のエントリで、projectsディレクトリにあるものは読みこむようにしてあったので、proxy.confもcotouch.confもnginx起動時に自動的に読み込まれることになる。</p>
<pre class="brush: xml; title: ; notranslate">
・・・・
http {
・・・・
 # Load config files from th/usr/local/nginx/conf/projects/ directory
 include /usr/local/nginx/conf/projects/*.conf;
}
</pre>
<p>ここまで変更してから、nginxの再起動を行う。</p>
<pre class="brush: xml; title: ; notranslate">
sudo /etc/init.d/nginx restart
</pre>
<p>すると、ちゃんとサブドメインでアプリが動き、さらに2枚同時に立ち上げると同期しているのも確認できた。<br />
<a href="http://cotouch.omusuhi.info/" target="_blank">cotouch.omusuhi.info</a></p>
<p>これで、複数のNodeアプリがあってもnginx側で管理できるようになった。<br />
次はphp-fpmでphpを動かしてみたい。<br />
余裕ができたらwordpressもnginxでどれだけパフォーマンスが良くなるのか試してみたいと考えている。</p>
]]></content:encoded>
			<wfw:commentRss>http://cross.hvn.to/?feed=rss2&#038;p=1838</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>さくらのVPS設定[7]-NginxとNode.jsを組み合わせた時のディレクトリ・グループ構成</title>
		<link>http://cross.hvn.to/?p=1753&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2581%2595%25e3%2581%258f%25e3%2582%2589%25e3%2581%25aevps%25e8%25a8%25ad%25e5%25ae%259a7-nginx%25e3%2581%25a8node-js%25e3%2582%2592%25e7%25b5%2584%25e3%2581%25bf%25e5%2590%2588%25e3%2582%258f%25e3%2581%259b%25e3%2581%259f%25e6%2599%2582%25e3%2581%25ae%25e3%2583%2587%25e3%2582%25a3%25e3%2583%25ac%25e3%2582%25af</link>
		<comments>http://cross.hvn.to/?p=1753#comments</comments>
		<pubDate>Wed, 16 May 2012 07:17:38 +0000</pubDate>
		<dc:creator>sib</dc:creator>
				<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[VPS]]></category>

		<guid isPermaLink="false">http://cross.hvn.to/?p=1753</guid>
		<description><![CDATA[改めてディレクトリ構成やグループとかを決め直した。 fooはシェルにログインする時のアカウントだ。 作業は以下 [...]]]></description>
			<content:encoded><![CDATA[<p>改めてディレクトリ構成やグループとかを決め直した。<br />
fooはシェルにログインする時のアカウントだ。<br />
作業は以下を参考にさせて頂いた。<br />
<a href="http://www.usupi.org/sysad/117.html" target="_blank">グループを使いこなす</a></p>
<p><span id="more-1753"></span></p>
<p><strong>ディレクトリ・グループ構成の検討</strong></p>
<p>グループ構成</p>
<p>group;nginx<br />
member;nginx</p>
<p><del datetime="2012-05-15T06:10:41+00:00">group;node<br />
member;node</del><br />
*nodeアカウントについては、必要になってから作成、今は保留する。</p>
<p>group;dev<br />
member;foo dev nginx (node root)<br />
*node、rootアカウントについては、必要になってから設定する。</p>
<p><del datetime="2012-05-15T22:14:39+00:00">/usr/local/nginx/<br />
owner;nginx<br />
group;nginx</del><br />
*問題が出るかもしれないので一通りの設定が落ち着くまで保留する。</p>
<p><del datetime="2012-05-15T22:14:39+00:00">/var/tmp/nginx/<br />
owner;nginx<br />
group;nginx</del><br />
*問題が出るかもしれないので一通りの設定が落ち着くまで保留する。</p>
<p>webアプリ公開用ディレクトリ。<br />
/var/webdev/<br />
owner;dev<br />
group;dev<br />
permission;775<br />
パーミッションはとりあえずwebdevを775にしてdevグループの物は動くようにしておいた。</p>
<p>hogeプロジェクト<br />
/var/webdev/hoge/<br />
hogeプロジェクトの静的部分をhtmlディレクトリ、nodeアプリ等の動的部分をappディレクトリの形にする。<br />
owner・groupはアプリに合わせて決めるが基本は以下の通りとしておく。</p>
<p>/var/webdev/hoge/html/<br />
owner;nginx<br />
group;nginx<br />
permission;644</p>
<p>/var/webdev/hoge/app/<br />
owner;foo<br />
group;foo<br />
permission;755</p>
<p><em>/var/webdev/html/hoge/<br />
/var/webdev/app/hoge/<br />
とすると、htmlディレクトリ以下、appディレクトリ以下でowner・groupをまとめれるのが良さそうだが、開発時にローカルマシンでプロジェクトを一箇所にまとめて管理しておきたかった事及びappがnodeのみでは無さそうなので、今回は採用しなかった。<br />
</em></p>
<p><strong>ディレクトリ・グループ設定</strong></p>
<p>devユーザーを作成する。アプリ名はとりあえずでindexにしておいた。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo useradd -s /sbin/nologin dev
</pre>
<p>補助グループに今まで入っていたグループも指定しておかないと、 補助グループから外されてしまう。<br />
これで一度失敗した。<br />
なのでまず補助グループを確認してから、それを含める形で再度指定する。</p>
<pre class="brush: xml; title: ; notranslate">
$ groups foo
foo : foo
$ sudo usermod -G dev,foo foo
$ groups foo
foo : foo dev

$ groups nginx
nginx : nginx
$ sudo usermod -G dev,nginx nginx
$ groups nginx
nginx : nginx dev
</pre>
<p>ユーザー確認する。</p>
<pre class="brush: xml; title: ; notranslate">
$ cat /etc/passwd
</pre>
<p>グループ確認する。</p>
<pre class="brush: xml; title: ; notranslate">
$ cat /etc/group
</pre>
<p>とりあえずindexのディレクトリを作成する。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo mkdir -p /var/webdev/index/{html,app}
$ cd /var/
$ sudo chown -R dev webdev
$ sudo chgrp -R dev webdev
$ sudo chmod 775 webdev
$ ls -l webdev
合計 4
drwxr-xr-x 4 dev dev 4096  5月 16 09:43 2012 index
</pre>
<p>各プロジェクトのアクセス権限については、また後で設定する。</p>
<p><strong>confファイルの調整</strong></p>
<p>プロジェクト毎に設定ファイルを置けるようにprojectsディレクトリを作成する。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo mkdir /usr/local/nginx/conf/projects/
</pre>
<p>ディレクトリ構成に合わせて設定ファイルの調整をする。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo nano /usr/local/nginx/conf/nginx.conf
</pre>
<p>ユーザーはnginxへ変更する。</p>
<pre class="brush: xml; title: ; notranslate">
user nginx;
</pre>
<p>worker_processesを決めるためにサイトをみると契約した<a href="http://vps.sakura.ad.jp/" target="_blank">さくらVPS1Gプラン</a>は仮想 2コアだった。</p>
<pre class="brush: xml; title: ; notranslate">
worker_processes  2;
</pre>
<p>デフォルトのroot指定をvar/webdev/index/へ変更する。<br />
プロジェクト毎に設定を読み込めるようにprojects/*.confをincludeする。</p>
<pre class="brush: xml; title: ; notranslate">
http {
 ・・・
 server {
  ・・・
      location / {
         root   /var/webdev/index/html;
         index  index.html index.htm;
      }
  ・・・
  }
  ・・・
 # Load config files from the /usr/local/nginx/conf/projects/ directory
 include /usr/local/nginx/conf/projects/*.conf;
}
</pre>
<p>これで契約したVPSをみてみる。<br />
<a href="http://www.omusuhi.info/" target="_blank">http://www.omusuhi.info/</a><br />
/var/webdev/index/html/にアップロードしてあった「おむすびコロン。」が表示されている。<br />
試しに適当なのを指定すると、<br />
<a href="http://www.omusuhi.info/a" target="_blank">http://www.omusuhi.info/a</a><br />
ちゃんと「404 Not Found」がでている。<br />
次回はnginxを導入した理由でもあるリバースプロクシの設定を行う。</p>
<p>追記・/var/www/としていたのをhttpdが使用するディレクトリと被るので/var/webdev/に変更した。</p>
]]></content:encoded>
			<wfw:commentRss>http://cross.hvn.to/?feed=rss2&#038;p=1753</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>さくらのVPS設定[6]-Nginxをpacoでインストール</title>
		<link>http://cross.hvn.to/?p=1694&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2581%2595%25e3%2581%258f%25e3%2582%2589%25e3%2581%25aevps%25e8%25a8%25ad%25e5%25ae%259a6-nginx%25e3%2582%2592paco%25e3%2581%25a7%25e3%2582%25a4%25e3%2583%25b3%25e3%2582%25b9%25e3%2583%2588%25e3%2583%25bc%25e3%2583%25ab</link>
		<comments>http://cross.hvn.to/?p=1694#comments</comments>
		<pubDate>Tue, 15 May 2012 21:03:01 +0000</pubDate>
		<dc:creator>sib</dc:creator>
				<category><![CDATA[Nginx]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[npm]]></category>
		<category><![CDATA[さくらのVPS]]></category>

		<guid isPermaLink="false">http://cross.hvn.to/?p=1694</guid>
		<description><![CDATA[ハイパフォーマンスHTTPサーバ Nginx入門を購入した。読んでいるとやっぱりnginxの再インストールをし [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.co.jp/gp/product/4048702270/ref=as_li_ss_tl?ie=UTF8&#038;tag=sibsib-22&#038;linkCode=as2&#038;camp=247&#038;creative=7399&#038;creativeASIN=4048702270">ハイパフォーマンスHTTPサーバ Nginx入門</a><img src="http://www.assoc-amazon.jp/e/ir?t=sibsib-22&#038;l=as2&#038;o=9&#038;a=4048702270" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />を購入した。読んでいるとやっぱりnginxの再インストールをしたくなってきた。さらにグループだとかも見直しがしたくなってきたのでnginxだけでなくOSの再インストールからはじめることにした。</p>
<p><a href="http://cross.hvn.to/?p=1642" target="_blank">mongoDBのインストールまで</a>は、今までと一緒で、nginxのインストールから変更となる。<br />
ソースインストールで、しかも再インストールがありそうなnginxはpacoで管理するのがよさそうだ。</p>
<p><a href="http://d.hatena.ne.jp/rx7/20081011/p2" target="_blank">&#8220;make install&#8221;したソフトウェアを管理できる超便利ツール「Paco」</a><br />
<a href="http://www.tk84.net/blog/%E3%80%8CPaco%E3%80%8D%E3%81%A7%E3%80%8Cmake%20uninstall%E3%80%8D%E3%81%A7%E3%81%8D%E3%81%AA%E3%81%84%E3%82%BD%E3%83%95%E3%83%88%E3%82%92%E5%89%8A%E9%99%A4%E3%81%99%E3%82%8B/" target="_blank">「Paco」で「make uninstall」できないソフトを削除する</a><br />
<a href="http://fedorakenken.at-ninja.jp/node16.html" target="_blank">yum,rpmで扱えないアプリケーションを管理するソフトpaco</a></p>
<p><span id="more-1694"></span></p>
<p><strong>pacoのインストール</strong><br />
インストールのために最新版を確認する。<br />
<a href="http://paco.sourceforge.net/" target="_blank">paco &#8211; a source code pacKAGE oRGANIZER for Unix/Linux</a><br />
2.0.9が最新版のバージョンなので、それをwgetし展開、configureする。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo mkdir /usr/local/src/paco
$ sudo wget http://downloads.sourceforge.net/paco/paco-2.0.9.tar.gz
$ sudo tar zxfv paco-2.0.9.tar.gz
$ cd paco-2.0.9
$ ./configure
・・
No package 'gtkmm-2.4' found
</pre>
<p>gtkmm-2.4がない模様だ。調べてみると、GUIインタフェース用らしいので要らないらしい。<br />
<a href="http://selfkleptomaniac.org/archives/730" target="_blank">pacoを導入</a><br />
というわけで、&#8211;disableにして再度configureしインストールする。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo ./configure --disable-gpaco
$ sudo make
$ sudo make install
</pre>
<p>logmeコマンドでPaco自身もアンインストールできるようにする。<br />
sudoで行おうとするとエラーが出る。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo make logme
make: *** [logme] エラー 2
</pre>
<p>suにチェンジしてlogmeするとうまくいった。</p>
<pre class="brush: xml; title: ; notranslate">
$ su
# make logme
# paco --version
paco-2.0.9  (28 June 2010)
Copyright (C) David Rosal &lt;davidrr@sourceforge.net&gt;
Protected by the GNU General Public License
</pre>
<p><strong>pacoでnginxをインストール。</strong><br />
nginxをpacoでインストールする手順を、こちらで確認させて頂いた。<br />
<a href="http://www.tk84.net/blog/%E3%81%95%E3%81%8F%E3%82%89VPS%E3%82%B5%E3%83%BC%E3%83%90%E3%81%ABnginx-1.1.15%E3%82%92%E3%82%BD%E3%83%BC%E3%82%B9%E3%81%8B%E3%82%89%E3%83%93%E3%83%AB%E3%83%89%E3%81%97%E3%81%A6%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%97%E3%81%9F%E3%81%A8%E3%81%8D%E3%81%AE%E3%83%A1%E3%83%A2/" target="_blank">さくらVPSサーバにnginx-1.1.15をソースからビルドしてインストールしたときのメモ</a></p>
<p>アプリが使用するnginxアカウントを作成する。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo useradd -s /sbin/nologin -d /usr/local/nginx -M nginx
</pre>
<p>nginxのビルドに必要なパッケージのインストールをする。重要ではないがIPアドレスから地理情報を取得できるGeoIPも、使えそうなので入れてみる。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo yum install gcc openssl-devel pcre-devel zlib-devel GeoIP*
</pre>
<p>前と同じくnginx_tcp_proxy_moduleをダウンロードしパッチを当てる。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo mkdir /usr/local/src/nginx
$ cd /usr/local/src/nginx
$ sudo wget http://nginx.org/download/nginx-1.2.0.tar.gz
$ sudo git clone https://github.com/yaoweibin/nginx_tcp_proxy_module.git
$ sudo tar zxvf nginx-1.2.0.tar.gz
$ cd nginx-1.2.0
</pre>
<p>前回とは違い今回はユーザ名指定し幾つかのオプションとnginx_tcp_proxy_moduleを加えてconfigureする。<br />
パス関連のオプション指定はコチラにまとまっていたので参考にさせて頂いた。<br />
<a href="http://www.lamnk.com/blog/computer/remember-to-specify-nginxs-temp-directory-path/" target="_blank">REMEMBER TO SPECIFY NGINX’S TEMP DIRECTORY PATH</a></p>
<pre class="brush: xml; title: ; notranslate">
$ sudo ./configure \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_geoip_module \
--with-http_flv_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi/ \
--http-scgi-temp-path=/var/tmp/nginx/scgi/ \
--add-module=../nginx_tcp_proxy_module/
・・・・
Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + md5: using OpenSSL library
  + sha1: using OpenSSL library
  + using system zlib library

  nginx path prefix: &quot;/usr/local/nginx&quot;
  nginx binary file: &quot;/usr/local/nginx/sbin/nginx&quot;
  nginx configuration prefix: &quot;/usr/local/nginx/conf&quot;
  nginx configuration file: &quot;/usr/local/nginx/conf/nginx.conf&quot;
  nginx pid file: &quot;/usr/local/nginx/logs/nginx.pid&quot;
  nginx error log file: &quot;/usr/local/nginx/logs/error.log&quot;
  nginx http access log file: &quot;/var/log/nginx/access.log&quot;
  nginx http client request body temporary files: &quot;/var/tmp/nginx/client/&quot;
  nginx http proxy temporary files: &quot;/var/tmp/nginx/proxy/&quot;
  nginx http fastcgi temporary files: &quot;/var/tmp/nginx/fcgi/&quot;
  nginx http uwsgi temporary files: &quot;/var/tmp/nginx/uwsgi/&quot;
  nginx http scgi temporary files: &quot;/var/tmp/nginx/scgi/&quot;
</pre>
<p>一時ファイルの場所も変更された模様だ。<br />
必要なフォルダを作成しインストールを行う。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo mkdir -p /var/tmp/nginx/{proxy,client,fcgi,uwsgi,scgi}
$ sudo make
$ sudo paco -D make install
</pre>
<p>エラーが出てくる。sudoではダメの模様なのでsuにチェンジしてインストールを試みるとうまくいった。</p>
<pre class="brush: xml; title: ; notranslate">
$ su
# paco -D make install
# paco -a
nginx-1.2.0  paco-2.0.9
</pre>
<p>paco -aするとnginxがpaco管理として入っているのが確認できた。</p>
<p>シンボリックリンクを張り起動してみる。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo ln -s /usr/local/nginx/sbin/nginx /sbin/nginx
$ sudo nginx
$ nginx -v
nginx version: nginx/1.2.0
</pre>
<p>「Welcome to nginx!」をブラウザで確認できたので停めておく。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo nginx -s quit
</pre>
<p>自動起動設定は前回の「<a href="http://cross.hvn.to/?p=1660" target="_blank">Nginx自動起動スクリプトの作成</a>」と同じなので割愛する。<br />
次回はnginxとnode併用でのディレクトリやグループ構成を行う。</p>
<p><iframe src="http://rcm-jp.amazon.co.jp/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=sibsib-22&#038;o=9&#038;p=8&#038;l=as4&#038;m=amazon&#038;f=ifr&#038;ref=ss_til&#038;asins=4048702270" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://cross.hvn.to/?feed=rss2&#038;p=1694</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>さくらのVPS設定[5]-Nginxインストールと起動設定</title>
		<link>http://cross.hvn.to/?p=1660&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2581%2595%25e3%2581%258f%25e3%2582%2589%25e3%2581%25aevps%25e8%25a8%25ad%25e5%25ae%259a5-nginx%25e3%2582%25a4%25e3%2583%25b3%25e3%2582%25b9%25e3%2583%2588%25e3%2583%25bc%25e3%2583%25ab%25e3%2581%25a8%25e8%25b5%25b7%25e5%258b%2595%25e8%25a8%25ad%25e5%25ae%259a</link>
		<comments>http://cross.hvn.to/?p=1660#comments</comments>
		<pubDate>Sun, 06 May 2012 07:56:00 +0000</pubDate>
		<dc:creator>sib</dc:creator>
				<category><![CDATA[Nginx]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[さくらのVPS]]></category>

		<guid isPermaLink="false">http://cross.hvn.to/?p=1660</guid>
		<description><![CDATA[nginxは「エンジンエックス」と読み、軽量高性能なHTTP、リバースプロキシ、メールプロキシだ。 公式からの [...]]]></description>
			<content:encoded><![CDATA[<p>nginxは「エンジンエックス」と読み、軽量高性能なHTTP、リバースプロキシ、メールプロキシだ。<br />
<a href="http://nginx.org/ja/" target="_blank">公式</a>からの説明を引用すると以下のようになる。</p>
<blockquote><p>
nginx [えんじんえっくす] は Igor Sysoev によって作られた HTTP とリバースプロキシのサーバで、メールプロキシサーバでもあります。Rambler (RamblerMedia.com) を含むロシアの多くの高負荷サイトで５年以上も動いています。Netcraft によると、nginx は 2010 年 4 月時点で 4.70% の人気サイトでサーバーとして、もしくはプロキシとして利用されています。成功例としては FastMail.FM や WordPress.com があります。
</p></blockquote>
<p>node.jsと同じくイベント駆動型アーキテクチャである。<br />
nginxを表に置きリバースプロキシと静的ファイルの取り扱いを行い、裏に動的ファイルを扱う形でNode.jsを置く方法でVPSサーバーを構築していこうと考えている。<br />
またwebsockeでリアルタイム通信を行う場合、そのままではリバースプロキシできないのでnginx_tcp_proxy_moduleというモジュールを使用する。この説明も加えておく。<br />
まず今回はモジュールを組み込んだnginxのインストールと自動起動の設定までを行う。<br />
<追記><a href="http://cross.hvn.to/?p=1694" target="_blank">いろいろと見直しをし再インストールした。</a></p>
<p><span id="more-1660"></span></p>
<p><strong>モジュールの組み込みとnginxのインストール</strong></p>
<p>nginxではsocket.ioのプロキシがうまく行かないようで、<a href="https://github.com/yaoweibin" target="_blank">yaoweibin</a>さんという方がモジュールを書いてくれている。このnginx_tcp_proxy_moduleを使用してリバースプロキシでもリアルタイム通信が出来るようにする。<br />
<a href="http://yaoweibin.github.com/nginx_tcp_proxy_module/" target="_blank">nginx_tcp_proxy_module</a></p>
<p>nginxのインストールは、<a href="http://heartbeats.jp/hbblog/2012/02/nginx02.html" target="_blank">nginx連載2回目: nginxのインストール</a>でも書かれているようにいくつかありyumコマンドでもインストールできるのだけど、モジュールの組み込みがインストール時にしかできないため、ソースをダウンロードしてパッチを当てる方法を取ることとした。</p>
<p>wgetする前に最新版の確認をする。<br />
<a href="http://nginx.org/download/" target="_blank">http://nginx.org/download/</a><br />
現時点ではnginx-1.2.0.tar.gzが最新版だった。<br />
ということで、ソース及びnginx_tcp_proxy_moduleをダウンロードしパッチを当てる。</p>
<pre class="brush: xml; title: ; notranslate">
$ mkdir nginx
$ cd nginx/
$ wget http://nginx.org/download/nginx-1.2.0.tar.gz
$ git clone https://github.com/yaoweibin/nginx_tcp_proxy_module.git
$ tar zxvf nginx-1.2.0.tar.gz
$ cd nginx-1.2.0
$ patch -p1 &lt; ../nginx_tcp_proxy_module/tcp.patch
</pre>
<p>nginx_tcp_proxy_moduleをオプションとしてconfigureしてみる。</p>
<pre class="brush: xml; title: ; notranslate">
$ ./configure --add-module=../nginx_tcp_proxy_module/
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=&lt;path&gt; option.
</pre>
<p>PCREライブラリというのがないらしいのでググってみると同じ症状の方がいてた。<br />
<a href="http://d.hatena.ne.jp/pirosikick/20101018/1287415379" target="_blank">CentOS5.5へのNginxのインストール</a><br />
pcre-develを入れれば良いみたいなので、yumでインストールし再度configureする。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo yum -y install pcre-devel
$ ./configure --add-module=../nginx_tcp_proxy_module/
Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library

  nginx path prefix: &quot;/usr/local/nginx&quot;
  nginx binary file: &quot;/usr/local/nginx/sbin/nginx&quot;
  nginx configuration prefix: &quot;/usr/local/nginx/conf&quot;
  nginx configuration file: &quot;/usr/local/nginx/conf/nginx.conf&quot;
  nginx pid file: &quot;/usr/local/nginx/logs/nginx.pid&quot;
  nginx error log file: &quot;/usr/local/nginx/logs/error.log&quot;
  nginx http access log file: &quot;/usr/local/nginx/logs/access.log&quot;
  nginx http client request body temporary files: &quot;client_body_temp&quot;
  nginx http proxy temporary files: &quot;proxy_temp&quot;
  nginx http fastcgi temporary files: &quot;fastcgi_temp&quot;
  nginx http uwsgi temporary files: &quot;uwsgi_temp&quot;
  nginx http scgi temporary files: &quot;scgi_temp&quot;
</pre>
<p>大丈夫なようだ。configパスなどは上記を参考にしていけば良いのだろうと検討を付けておきながらインストールをする。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo make
$ sudo make install
</pre>
<p><a href="http://d.hatena.ne.jp/shim0mura/20120110/1326198429" target="_blank">入門！ nginx</a>を参考にして、シンボリックリンクを張り機動してみる。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo ln -s /usr/local/nginx/sbin/nginx /sbin/nginx
$ sudo nginx
</pre>
<p>サイトで「Welcome to nginx!」の表示を確認できたので起動停止しておく。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo nginx -s quit
</pre>
<p><strong>Nginx自動起動スクリプトの作成</strong></p>
<p>サーバーを起動したらnginxも自動起動するように設定ファイルを作成する。<br />
<a href="http://shiken.infrabu.info/nginx/nginx%E3%82%92%E3%82%BD%E3%83%BC%E3%82%B9%E3%81%8B%E3%82%89%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%EF%BC%88%EF%BC%8B%E5%9F%BA%E6%9C%AC%E8%A8%AD%E5%AE%9A%EF%BC%89/" target="_blank">nginxをソースからインストール（＋基本設定）</a>を参考にして<a href="http://wiki.nginx.org/RedHatNginxInitScript" target="_blank">Red Hat Nginx Init Script</a>のファイルをベースに機動パスと設定ファイルのパスを変更した。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo nano /etc/init.d/nginx
</pre>
<p><a href="http://wiki.nginx.org/RedHatNginxInitScript" target="_blank">Red Hat Nginx Init Script</a>をコピー＆ペーストする。</p>
<p>機動パス変更</p>
<pre class="brush: xml; title: ; notranslate">
# NGINX_CONF_FILE=&quot;/etc/nginx/nginx.conf&quot;
NGINX_CONF_FILE=&quot;/usr/local/nginx/conf/nginx.conf&quot;
</pre>
<p>設定ファイルのパス変更</p>
<pre class="brush: xml; title: ; notranslate">
# nginx=&quot;/usr/sbin/nginx&quot;
nginx=&quot;/usr/local/nginx/sbin/nginx&quot;
</pre>
<p>そして、コチラを参考に起動時設定スクリプトとして登録する。<br />
<a href="http://d.hatena.ne.jp/pirosikick/20101019/1287502384" target="_blank">CentOS用 Nginx起動スクリプト</a></p>
<p>実行権限を付与する。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo chmod a+x /etc/init.d/nginx
</pre>
<p>起動時に実行するスクリプトとして登録する。<br />
ランレベル3と5の時に起動スクリプトを実行する。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo /sbin/chkconfig --add nginx
$ sudo /sbin/chkconfig --list | grep nginx
nginx          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
$ sudo /sbin/chkconfig --level 35 nginx on
$ sudo /sbin/chkconfig --list | grep nginx
nginx          	0:off	1:off	2:off	3:on	4:off	5:on	6:off
</pre>
<p>VPSのコントロールパネルで再起動して、サイトで確認すると、「Welcome to nginx!」の表示になっており無事に自動機動の確認できた。</p>
<p>今回はここまで。リバースプロクシとNode.jsアプリの移動は次回行う予定にしている。<br />
./configureオプションでできることあたりの把握がまだできていないので、必要になったときに再インストールしつつ調べようかなと考えている。</p>
]]></content:encoded>
			<wfw:commentRss>http://cross.hvn.to/?feed=rss2&#038;p=1660</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>さくらのVPS設定[4]-MongoDBのインストール</title>
		<link>http://cross.hvn.to/?p=1642&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2581%2595%25e3%2581%258f%25e3%2582%2589%25e3%2581%25aevps%25e8%25a8%25ad%25e5%25ae%259a4-mongodb%25e3%2581%25ae%25e3%2582%25a4%25e3%2583%25b3%25e3%2582%25b9%25e3%2583%2588%25e3%2583%25bc%25e3%2583%25ab</link>
		<comments>http://cross.hvn.to/?p=1642#comments</comments>
		<pubDate>Sat, 05 May 2012 03:59:24 +0000</pubDate>
		<dc:creator>sib</dc:creator>
				<category><![CDATA[VPS]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[さくらのVPS]]></category>

		<guid isPermaLink="false">http://cross.hvn.to/?p=1642</guid>
		<description><![CDATA[引き続きMongoDBだが、これも以前のエントリとほぼ同じだ。 VPS作業メモ[8]-MongoDB 参考にさ [...]]]></description>
			<content:encoded><![CDATA[<p>引き続きMongoDBだが、これも以前のエントリとほぼ同じだ。<br />
<a href="http://cross.hvn.to/?p=817" target="_blank">VPS作業メモ[8]-MongoDB</a><br />
参考にさせて頂くサイトも同じだ。<br />
<a href="http://blog.madapaja.net/2011/09/20-mongodb-1-mongodbjp.html" target="_blank">2.0 からはじめる MongoDB – 第1回 #mongodbjp</a><br />
MongoDB公式サイトでの記事はこちらにある。<br />
<a href="http://jp.docs.mongodb.org/master/tutorial/install-mongodb-on-redhat-centos-or-fedora-linux/" target="_blank">RedHat Enterprise、CentOS、またはFedora LinuxにMongoDBをインストール</a></p>
<p><span id="more-1642"></span></p>
<p>32bitか64bitか確認<br />
<a href="http://cross.hvn.to/?p=303" target="_blank">32bitの場合「i686 i686 i386 」と表示され、64bitの場合はX86_64やamd64となる。</a></p>
<pre class="brush: xml; title: ; notranslate">
$ uname -a
Linux VPSホスト名 2.6.32-220.7.1.el6.x86_64 #1 
SMP Wed Mar 7 00:52:02 GMT 2012 
x86_64 x86_64 x86_64 GNU/Linux
</pre>
<p>x86_64なので64bitだった。なので<a href="http://jp.docs.mongodb.org/master/tutorial/install-mongodb-on-redhat-centos-or-fedora-linux/#configure-package-management-system-yum" target="_blank">64bit版でリポジトリ登録</a>を行う。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo nano /etc/yum.repos.d/10gen.repo
[sudo] password for foo: 

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1
</pre>
<p>一度yumでローカルパッケージデータベースをアップデートした後にmongoDBパッケージをインストールする。インストール時に何か聞かれるのでyを押す。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo yum update
$ sudo yum install mongo-10gen mongo-10gen-server
・・
Total download size: 34 M
Installed size: 82 M
Is this ok [y/N]: y
Downloading Packages:
・・
Installed:  mongo-10gen.x86_64 0:2.0.4-mongodb_1   
            mongo-10gen-server.x86_64 0:2.0.4-mongodb_1                        
Complete!
</pre>
<p>インストールされたので起動してみる。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo service mongod start
Starting mongod: forked process: 11763
all output going to: /var/log/mongo/mongod.log
[  OK  ]
</pre>
<p>ストップして別方法で起動してみる。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo service mongod stop
Stopping mongod:[  OK  ]
$ sudo /etc/init.d/mongod start
Starting mongod: forked process: 11798
[  OK  ]
all output going to: /var/log/mongo/mongod.log
</pre>
<p>バージョン確認</p>
<pre class="brush: xml; title: ; notranslate">
$ mongod --version
db version v2.0.4, pdfile version 4.5
Sat May  5 12:44:35 git version: 329f3c47fe8136c03392c8f0e548506cb21f8ebf
</pre>
<p>chkconfigで起動時に開始するように設定する。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo chkconfig --add mongod
</pre>
<p>これもNode.jsに続き慣れた作業だったので楽だった。</p>
]]></content:encoded>
			<wfw:commentRss>http://cross.hvn.to/?feed=rss2&#038;p=1642</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>さくらのVPS設定[3]-Node.jsのインストール</title>
		<link>http://cross.hvn.to/?p=1634&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2581%2595%25e3%2581%258f%25e3%2582%2589%25e3%2581%25aevps%25e8%25a8%25ad%25e5%25ae%259a3-node-js%25e3%2581%25ae%25e3%2582%25a4%25e3%2583%25b3%25e3%2582%25b9%25e3%2583%2588%25e3%2583%25bc%25e3%2583%25ab</link>
		<comments>http://cross.hvn.to/?p=1634#comments</comments>
		<pubDate>Sat, 05 May 2012 01:13:45 +0000</pubDate>
		<dc:creator>sib</dc:creator>
				<category><![CDATA[Node.js]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[さくらのVPS]]></category>

		<guid isPermaLink="false">http://cross.hvn.to/?p=1634</guid>
		<description><![CDATA[nvmでnode.jsのバージョンを、npmでパッケージを管理する方法を取る。 nvm (Node Versi [...]]]></description>
			<content:encoded><![CDATA[<p>nvmでnode.jsのバージョンを、npmでパッケージを管理する方法を取る。</p>
<p>nvm (Node Version Manager)<br />
複数バージョンを切り替え</p>
<p>npm (Node Package Manager)<br />
アプリごとの使用パッケージを管理。</p>
<p>基本は以前のエントリと同じだ。<br />
<a href="http://cross.hvn.to/?p=348" target="_blank">VPS作業メモ[6]-node.js</a><br />
こちらも、確認のために見ていた。<br />
<a href="http://blog.summerwind.jp/archives/1464" target="_blank">Node.jsの管理はnvmで</a><br />
<a href="http://d.hatena.ne.jp/xyk/20120131/1327998901" target="_blank">CentOS5.5 に node.js をインストールする</a></p>
<p><span id="more-1634"></span></p>
<p>まずはビルドに必要なOpenSSLの開発用パッケージをインストールする。</p>
<pre class="brush: xml; title: ; notranslate">
$ sudo  yum -y install openssl-devel
</pre>
<p>githubにあるnvmのリポジトリをクローンする。</p>
<pre class="brush: xml; title: ; notranslate">
$ git clone git://github.com/creationix/nvm.git ~/.node
Initialized empty Git repository in /home/sib/.node/.git/
remote: Counting objects: 323, done.
remote: Compressing objects: 100% (182/182), done.
remote: Total 323 (delta 172), reused 273 (delta 133)
Receiving objects: 100% (323/323), 44.90 KiB, done.
Resolving deltas: 100% (172/172), done.
</pre>
<p>.でシェルスクリプトを実行しインストールする。</p>
<pre class="brush: xml; title: ; notranslate">
$ . ~/.node/nvm.sh
</pre>
<p>nodeのサイトで最近版のバージョン確認をする。<br />
<a href="http://nodejs.org/">http://nodejs.org/</a><br />
今はv0.6.17のようだ。</p>
<p>nvmでnode.jsの最新版をインストールする。</p>
<pre class="brush: xml; title: ; notranslate">
$ nvm install v0.6.17
・・・
Now using node v0.6.17
~/.node/v0.6.17/bin/npm
</pre>
<p>node、npmそれぞれを確認する。</p>
<pre class="brush: xml; title: ; notranslate">
$ node -v
v0.6.17
$ npm -v
1.1.21
</pre>
<p>.bashrcにnvmの設定を書いておきいちいち起動しなくても済むようにする。</p>
<pre class="brush: xml; title: ; notranslate">
$ nano ~/.bashrc
. ~/.node/nvm.sh
nvm use v0.6.17
</pre>
<p>一度離脱して確認</p>
<pre class="brush: xml; title: ; notranslate">
$ exit
$ ssh -p 10022 foo@VPSのIPアドレス
SAKURA Internet [Virtual Private Server SERVICE]
Now using node v0.6.17
</pre>
<p>大丈夫。</p>
<p>開発系ツールのグローバルインストールをしておく。</p>
<pre class="brush: xml; title: ; notranslate">
$ npm install node-dev -g
$ npm install node-inspector -g
</pre>
<p>出来上がったアプリを永続化するために<a href="https://github.com/nodejitsu/forever" target="_blank">forever</a>もいれる。<br />
sudoだとエラーが出たのでsuにチェンジしてからインストールした。</p>
<pre class="brush: xml; title: ; notranslate">
$ su
# npm install forever -g
</pre>
<p>このままだとsudoしたときにnpmが効かなくなるのでvisudoでetc/sudoersを編集して実行ユーザから環境変数を引き継ぐようにする。<br />
<a href="http://d.hatena.ne.jp/aquarla/20120414/1334421989" target="_blank">新しくなった さくらVPS + nginx + Sinatra でプライベート Gyazo サーバを構築しよう<br />
</a></p>
<pre class="brush: xml; title: ; notranslate">
$ su
# visudo

Defaults    env_reset
Defaults    env_keep =  &quot;COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS&quot;
・・・・
Defaults    env_keep += &quot;PATH&quot;
# 最後にこの一行を追加
・・・・
# Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
# この一行をコメントアウト
</pre>
<p>以上でNode.jsのインストールは終りだ。</p>
]]></content:encoded>
			<wfw:commentRss>http://cross.hvn.to/?feed=rss2&#038;p=1634</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
