lighttpdにPHP5を組み込む

PHP, Webサーバ, lighttpd

10:23:57, by admin Email , 270 words, 5508 views   Japanese (JP) del.icio.us

Apacheサヨウナラも近い!!

(ノ・・)ン。。。。。。(((●コロコロッ

私は昔からApacheが嫌いだった。
Apacheといえば業界標準のWebサーバソフトウェア。
実績はNo.1といえる。
だが、どうもサーバ保守業界というのは得てして使いにくいものを選択する。
Apacheしかり、qmailしかり。
なぜ?


私は昔からApacheが嫌いだった。
全くまとまりのない設定ファイル。
設定したとおりに動かない不思議な挙動。
プロセスが山盛り起動する仕組み。
どれをとっても好きになる要素がなかった。
Apache2.2になってそのあたりがまとまってきたが。
それでも嫌悪感はぬぐえなかった。

私は昔からApacheが嫌いだった。
どうにかして他のWebサーバにしたかった。
IISはWindowsオンリーの時点で使用不可。
その他はと言うと、ものもよくわからないものばかり。


何か良いものはないだろうか?



ある日何気なくページを眺めていると、
lighttpdが良いらしいという情報を掴んだ。
lighttpd(ライトティーピーディ)とは?
Security, speed, compliance, and flexibility--all of these describe LightTPD which is rapidly redefining efficiency of a webserver; as it is designed and optimized for high performance environments. With a small memory footprint compared to other web-servers, effective management of the cpu-load, and advanced feature set (FastCGI, CGI, Auth, Output-Compression, URL-Rewriting and many more) LightTPD is the perfect solution for every server that is suffering load problems. And best of all it's Open Source licensed under the revised BSD license.


Apacheと同等の機能を保有する軽量が売りのWebサーバ。
機能は結構充実している。
面白そうなのがMySQLでバーチャルホストの設定ができるということだ。
設定ツールを作成するなどして繋ぎ込みをしやすい。

Rewriteの機能に関してはApacheの方が遙かに上だが、
そこは重要じゃない。
重要なのはApacheよりもCGI動作が高速だと言うこと。
RubyやPython、Perlなどの利用者にはうってつけといえる。

mod_perlは意味不明な仕様だし、mod_rubyは使い物にならない。
だが、そもそもmod_perlやmod_rubyが必要な理由は"ApacheのCGIが遅い"というところにある。
"PHPをモジュールで組み込む"というのは元々からして、
"ApacheのCGIが遅い"というところにある。
なら高速なCGIだったら、別にCGI版でも良いわけだ。


では将来的にlighttpdをメインで使うことを見越して(妄想しすぎ?)。
lighttpdにPHPをインストールしてみた。


[More:]

lighttpdをインストール
OSは例によってRedhat Enterprise Linux 3だ。
なので、起動プログラムはマニュアルのものと違うものを使用する。
$ ./cofigure --prefix=/usr
$ make
# make install
# cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd
# cp doc/sysconfig.lighttpd /etc/sysconfig/lighttpd
# mkdir /etc/lighttpd/
# cp doc/lighttpd.conf /etc/lighttpd/lighttpd.conf
# /etc/init.d/lighttpd -t -f /etc/lighttpd/lighttpd.conf
# /etc/init.d/lighttpd -D -f /etc/lighttpd/lighttpd.conf

あっさりインストールできた。
起動してみると、
プロセスが一つだけ常駐している。



●PHPのインストール
これは現在すでにApache2.2+PHP5が動作しているので、
コンパイルした時に被らないようにしなければならない。
このサイトもそれで見ているわけだし。
なので、Apache設定やapxs設定は撤去しておく必要がある。
--with-apxs=/usr/local/apache/bin/apxs
--with-apxs2=/usr/local/apache2/bin/apxs
などの設定は除去しておこう。
あと、決してmake installをしないように。
php.iniは現行のものと共通でも問題ない。

lighttpdにはFastCGIは必須なので、
--enable-fastcgiを追加しておく。

$ ./configure --enable-fastcgi --enable-discard-path --enable-force-redirect ~その他
$ make
# cp sapi/cgi/php /usr/local/bin/php-cgi

試しに実行してみる。

[dozo@dozo cgi]$ /usr/local/bin/php-cgi -v
PHP 5.1.6 (cgi-fcgi) (built: Oct 29 2006 21:53:19)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies


問題なさそうだ。


lighttpdのCGI設定
/etc/lighttdp/lighttdp.confに設定を追加する。
server.modules = (
"mod_fastcgi",
)

fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/local/bin/php-cgi",
"socket" => "/tmp/php.socket",
)))


lighttpdを再起動してみると、
php-cgiプロセスが常駐していた。
phpinfoを確認してみる。

Server API CGI/FastCGI



(・∀・)もんだいなーい

これでしばらく運用してみよう。



Trackback address for this post:

http://hain.jp/htsrv/trackback.php/94

Comments, Trackbacks:

No Comments/Trackbacks for this post yet...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
This is a captcha-picture. It is used to prevent mass-access by robots.

Please enter the characters from the image above. (case insensitive)

powered by b2evolution

shinobi

Neighbors
Relative
Favorites
PR

極論istの技術屋を始めて早幾年。 流れの速い業界の波にもまれながらも精一杯生きている様をとくとごらんあれ。

Archives
スポンサー

Latest bookmark
Search

Categories

Who's Online?
Misc
Syndicate this blog XML

Valid XHTML 1.0! Valid CSS! Valid RSS 2.0! Valid Atom 1.0!