lighttpd 日本語セットアップサイト


Preface :

LightTPD (Light footprint + httpd = LightTPD) とは、セキュリティ、スピード、操作性、および柔軟性−−これらすべての事柄において、ウェブサーバの効率を最適化します。そんな LightTPD を説明します。LightTPDは、高性能環境のために設計され、最適化されているので少ないメモリによるフットプリントを他のサーバと比較すると、LightTPD はcpuロードアベレージの効果的な管理、そして、高度な機能セット(FastCGI、CGI、Auth、出力圧縮、URL-Rewriting、およびその他多く)を持つことで現在負荷問題を抱えているあらゆるサーバのための完全な解決策になりえます。 そして、それは最もよく、改変された BSDライセンス の下で認可されているオープンソースです。
以下のサイトでApacheとlighttpdのパフォーマンスの比較データが参照できます。
http://www.lighttpd.net/benchmark/
http://litespeedtech.com/products/webserver/benchmark/
http://journal.paul.querna.org/articles/2005/06/24/debunking-lighttpd
LightTPDの著作権は、 Jan Kneschke にあります。

本サイトは、LightTPDのセットアップを日本語で紹介して普及を目指すサイトであって、LightTPDを開発している団体では有りません。


◆ オフィシャルサイト

http://www.lighttpd.net/  です。


◆ 優れた機能群

・基本機能
* バーチャルホスト
* バーチャルディレクトリ・リスト
* URL-Rewriting, HTTP-Redirects
* ファイルの自動的な満了
* ビッグファイルサポート(64bit fileoffsets)
* レングス(開始と終わり、開始-、-終わり、複数のレングス)
* 透過的なキャッシュによるオンザフライアウトプット圧縮
 deflate, gzip, bzip2
* 認証
 ベーシック、ダイジェスト

 バックエンド : プレインファイル、htpasswd、htdigest、ldap
* 安全なアプリケーションを素早くダウンロードします
* サーバサイドインクルード(SSI)
* ユーザトラッキング
* FastCGICGISSI

PHPサポート
* apache + mod_php4と 同等、もしくはそれより高速 
* FastCGIプロセスの過程をふむためのユーティリティを含みます(PHP 4.3.x以降が必要)
* FastCGI および CGI インタフェースを利用します
* support Code Caches like Turckmm、APC、または eaccelarator
* ロードバランスFastCGI
(FastCGIを通った複数のPHP-サーバを1つのウェブサーバで実現)

・セキュリティ機能
* chroot(), set UID, set GID
* プロテクティング docroot
* 厳密なHTTPヘッダーパージング


◆ 動作プラットフォーム

lighttpdのリリースは、少なくとも以下のプラットフォームで動作します。

* Linux(バイナリパッケージは、FC3、SuSE、Debian、Gentoo、PLD-Linux、OpenWRT)
* BSD(FreeBSD、NetBSD、OpenBSD、MacOS X)
* SGI IRIX
* Windows(Cygwin)

清潔にコンパイルされます。

* Solaris
* AIX

そして、様々な他のPOSIXコンパチブルOS。


◆ ダウンロード

* http://www.lighttpd.net/download/

Mirrors

* http://mirrors.cat.pdx.edu/lighttpd/ ポートランド州立大学(RHEL & CentOS & Vine BuildSources)

External Sources

* Gentoo (included)
* PLD Linux (included)
* Fedora 5 Extra i386 Fedora 6 Extra i386 (included)
* ArchLinux
* Ubuntu dapper
* Debian unstable
* FreeBSD (included)
* NetBSD (pkgsrc)
* OpenBSD
* Windows/Cygwin
* Windows Install (no cygwin required)
* Mac OS X (DarwinPorts)
* Linux/Zaurus (pdaXrom)
* Linux/ARM (Linksys NSLU2)
* Linux/MIPS (OpenWRT)


◆ インストール

■ ソースインストール編( LightTPD + PHP + Postgresql連携 )

インストール環境)
サーバOS:Slackware10 & Nature's Linux & Debian GNU/Linux etch
データベースエンジン : Postgresql-8.1.3
PHPエンジン : php-5.1.2

サーバOS:Nature's Linux1.3
データベースエンジン:Postgresql-8.0.4
PHPエンジン:php-4.4.1

注:
lighttpd 1.5バージョンは、libgtk2.0以上が必須のようだ。ソースのconfigureの時に、gthreadクラスをチェックするのでインスコされてないとエラーが出るから注意すること。

1.FastCGIのインストール
FastCGI のインストール lighttpd で CGI を動作させるには、 FastCGI が必ず必要。Perlスクリプトを使うもPHPを使うも、FastCGI が必要のようだ。
2006年4月現在で、 fcgi-2.4.0.tar.gz が最新であった。

# cd /usr/local/src
# wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
# tar xvfz fcgi-2.4.0.tar.gz
# cd fcgi-2.4.0
# ./configure
# make
# make install

Perlライブラリをインストールする。例の如く、Perl CPAN からインストールする。

# perl -MCPAN -e shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.7601)
ReadLine support available (try 'install Bundle::CPAN')

cpan> install FCGI

cpan> install CGI::Fast

cpan> quit
Terminal does not support GetHistory.
Lockfile removed.

2.Perlの正規表現ライブラリlibpcreのインストール
lighttpd は、Perlの正規表現ライブラリ libpcre ( Perl Compatible Regular Expressions ) のインストールを必要としている。
2006年4月現在で、 pcre-6.6.tar.gz が最新であった。

# cd /usr/local/src
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-6.6.tar.gz
# tar xvfz pcre-6.6.tar.gz
# cd pcre-6.6
# ./configure
# make
# make install

3.PHPのインストール
PHP を使うには、FastCGI が必要でCGI版PHPと言うことになる。CGI版PHPを作るには、PHPをconfigureするとき、オプションパラメータでfastcgiをインクルードする必要がある。したがって、lighttpd で PHP を FastCGI として使う場合は、--enable-fastcgi とする。さらに、その準備として、デフォルトでは、 zlib のインストールと、なんだか libxml2 が必須のようである。また、データベースエンジンは、 Postgresql が既にインストールされているものとする。
ここ では、2006年4月現在、 php-5.1.2.tar.gz が最新であった。
注:fastcgiを使う場合には、2007年7月現在のPHP4の最新バージョンの動作確認は取っているがPHP5の最新バージョンには対応してなかった。ここいら辺はよく注意して欲しい。

# cd /usr/local/src
# wget http://jp.php.net/get/php-5.1.2.tar.gz/from/this/mirror
# tar xvfz php-5.1.2.tar.gz
# cd php-5.1.2
# ./configure \
>--enable-fastcgi \
>--enable-discard-path \
>--enable-force-cgi-redirect \
>--enable-mbstring \
>--enable-mbregex \
>--enable-mbstr-enc-trans \
>--enable-iconv \
>--enable-trans-sid \
>--with-pgsql=/usr/local/pgsql \
>--with-zlib=/usr --with-zlib-dir=/usr
# make
# make install

php.iniを設置する。
# cp php.ini-dist /usr/local/lib/php.ini

4.ログローティションモジュールをインストールする
cronolog
をインストールする。lighttpdには、ログローティション機能が無い。そのため、 cronolog と言うログのローティションエンジンをインストールする。
2006年4月現在で、 cronolog-1.6.2 が最新であった。

# cd /usr/local/src
# wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
# tar xvfz cronolog-1.6.2.tar.gz
# cd cronolog-1.6.2
# ./configure
# make
# make install

5.lighttpdのインストール
いよいよ、ここで目玉の lighttpd をインストールする。ゲットする場所は、もちろん オフィシャルサイトの ここ
2006年4月現在で、 lighttpd-1.4.11.tar.gz が最新であった。

# cd /usr/local/src
# wget http://www.lighttpd.net/download/lighttpd-1.4.11.tar.gz
# tar xvfz lighttpd-1.4.11.tar.gz
# cd lighttpd-1.4.11
# ./configure
# make
# make install
# ln -s /usr/local/sbin/lighttpd /usr/sbin/lighttpd

1)Slackware10の場合
# cp doc/rc.lighttpd.redhat /etc/rc.d/rc.lighttpd
# chmod 755 /etc/rc.d/rc.lighttpd

2)Nature's Linux1.3の場合
# cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd
# chmod 755 /etc/init.d/lighttpd

# cp doc/lighttpd.conf /usr/local/etc/

6.lighttpd.confの編集
lighttpd.confを編集する。
ここでのコンフィグは、以下をポリシーとして設定する。

@ cgiを使う
A phpを使う
B ドキュメントルートは、/usr/local/apache/htdocs
C ユーザ公開ディレクトリを設定(public_html)
D アクセスログは、cronologでローティションする
E ssiを利用する
F Script Aliasを /cgi-bin/ /icons/ へ設定する
G indexファイルを、index.php、index.html、index.htm、index.cgi、index.pl、default.htmlに設定する

# vi /usr/local/etc/lighttpd.conf

# httpdサーバが使うモジュールの選択
server.modules = (
             "mod_fastcgi",
             "mod_cgi",
             "mod_rewrite",
             "mod_userdir",

             "mod_access",
             "mod_auth",
             "mod_setenv",
             "mod_ssi",
             "mod_simple_vhost",
             "mod_accesslog" )

注:lighttpd.confでmod_fastcgiとmod_cgiを先頭に宣言しないと、lighttpd起動時エラーが出るので気を付けること。

# ドキュメントルート
server.document-root = "/usr/local/apache/htdocs/"

# ユーザ公開ディレクトリ名
userdir.path = "public_html"

# ユーザ公開ディレクトリパス(通常は、 /home/ で良いと思う)
userdir.basepath = "/home/"

# エラーログパス
server.errorlog = "/usr/local/apache/logs/error_log"

# cgi-bin と iconsのaliasを作る(apacheで言うScriptAliasのこと)
alias.url       = (
              "/cgi-bin/" => "/usr/local/apache/cgi-bin/",
              "/icons/" => "/usr/local/apache/icons/"
              )

# Apache の Option Indexes と同じ意味。downloadディレクトリにHTTPダウンロード領域を作る。
$HTTP["url"] =~"/download" {
               dir-listing.activate = "enable"
               }

# indexファイルネームパターン
index-file.names = ( "index.php", "index.html",
              "index.htm", "default.htm",
              "index.cgi", "index.pl" )

# mimetype
mimetype.assign = (
            ".pdf" => "application/pdf",
            ".sig" => "application/pgp-signature",
            ".spl" => "application/futuresplash",
            ".class" => "application/octet-stream",
            ".ps" => "application/postscript",
            ".torrent" => "application/x-bittorrent",
            ".dvi" => "application/x-dvi",
            ".gz" => "application/x-gzip",
            ".pac" => "application/x-ns-proxy-autoconfig",
            ".swf" => "application/x-shockwave-flash",
            ".tar.gz" => "application/x-tgz",
            ".tgz" => "application/x-tgz",
            ".tar" => "application/x-tar",
            ".zip" => "application/zip",
            ".mp3" => "audio/mpeg",
            ".m3u" => "audio/x-mpegurl",
            ".wma" => "audio/x-ms-wma",
            ".wax" => "audio/x-ms-wax",
            ".ogg" => "application/ogg",
            ".wav" => "audio/x-wav",
            ".gif" => "image/gif",
            ".jpg" => "image/jpeg",
            ".jpeg" => "image/jpeg",
            ".png" => "image/png",
            ".xbm" => "image/x-xbitmap",
            ".xpm" => "image/x-xpixmap",
            ".xwd" => "image/x-xwindowdump",
            ".css" => "text/css",
            ".html" => "text/html",
            ".htm" => "text/html",
            ".js" => "text/javascript",
            ".asc" => "text/plain",
            ".c" => "text/plain",
            ".cpp" => "text/plain",
            ".log" => "text/plain",
            ".conf" => "text/plain",
            ".text" => "text/plain",
            ".txt" => "text/plain",
            ".dtd" => "text/xml",
            ".xml" => "text/xml",
            ".mpeg" => "video/mpeg",
            ".mpg" => "video/mpeg",
            ".mov" => "video/quicktime",
            ".qt" => "video/quicktime",
            ".avi" => "video/x-msvideo",
            ".asf" => "video/x-ms-asf",
            ".asx" => "video/x-ms-asf",
            ".wmv" => "video/x-ms-wmv",
            ".bz2" => "application/x-bzip",
            ".tbz" => "application/x-bzip-compressed-tar",
            ".tar.bz2" => "application/x-bzip-compressed-tar"
             )

# アクセスログファイルパス(cronologでlogのローティションを行うので以下のように設定)
accesslog.filename = "|/usr/local/sbin/cronolog /usr/local/apache/logs/access_log.%Y%m%d"

# Apache LogFormatに対応する設定
accesslog.format = "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""

# サーバサービスポートの設定
server.port = 80

# ErrorDocument 404設定
server.error-handler-404 = "/404.html"

# pidファイルパス
server.pid-file = "/var/run/lighttpd.pid"

# lighttpd ユーザ
server.username = "nobody"

# lighttpd グループ
server.groupname = "nobody"

# FastCgiConfig:ここでは、fastcgiを使ってphpを動かす設定をしている
fastcgi.server = ( ".php" =>
            ( "localhost" =>
             (
              "socket" => "/tmp/php-fastcgi.socket",
              "bin-path" => "/usr/local/bin/php-cgi"
             )
            ),
            ".php4" =>
            ( "localhost" =>
             (
              "socket" => "/tmp/php-fastcgi.socket",
              "bin-path" => "/usr/local/bin/php-cgi"
             )
            ),
            ".php3" =>
            ( "localhost" =>
             (
              "socket" => "/tmp/php-fastcgi.socket",
              "bin-path" => "/usr/local/bin/php-cgi"
             )
            )
           )

# AddHandler cgi-scriptを設定
cgi.assign = ( ".pl" => "/usr/bin/perl",
         ".cgi" => "/usr/bin/perl" )

# ssiを利用する
ssi.extension = ( ".shtml" )

7.起動スクリプトを作る
ここでのlighttpdは、slackwareにインストールしたのでslackwareの起動スクリプトに編集する。

1) Slackware10の場合

# vi /etc/rc.d/rc.lighttpd
#!/bin/sh
#
# lighttpd Startup script for the lighttpd server

if [ -z "$LIGHTTPD_CONF_PATH" ]; then
LIGHTTPD_CONF_PATH="
/usr/local/etc/lighttpd.conf"
fi

prog="lighttpd"
lighttpd="/usr/sbin/lighttpd"
RETVAL=0

start() {
echo -n $"Starting $prog: "
$lighttpd -f $LIGHTTPD_CONF_PATH
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
killall $lighttpd

killall php
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}

reload() {
echo -n $"Reloading $prog: "
killall $lighttpd -HUP

killall php -HUP
RETVAL=$?
echo
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
fi
;;
reload)
reload
;;
status)
status $lighttpd
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
RETVAL=1
esac

exit $RETVAL

2)Nature's Linux1.3の場合
[VFS-root@michi ]# vi /etc/init.d/lighttpd
#!/bin/sh
#
# lighttpd Startup script for the lighttpd server
#
# chkconfig: - 85 15
# description: Lightning fast webserver with light system requirements
#
# processname: lighttpd
# config: /etc/lighttpd/lighttpd.conf
# config: /etc/sysconfig/lighttpd
# pidfile: /var/run/lighttpd.pid
#
# Note: pidfile is assumed to be created
# by lighttpd (config: server.pid-file).
# If not, uncomment 'pidof' line.

# Source function library
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/lighttpd ]; then
. /etc/sysconfig/lighttpd
fi

if [ -z "$LIGHTTPD_CONF_PATH" ]; then
LIGHTTPD_CONF_PATH="
/usr/local/etc/lighttpd.conf"
fi

prog="lighttpd"
lighttpd="/usr/sbin/lighttpd"
RETVAL=0

start() {
echo -n $"Starting $prog: "
daemon $lighttpd -f $LIGHTTPD_CONF_PATH
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
killproc $lighttpd

killall php
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}

reload() {
echo -n $"Reloading $prog: "
killproc $lighttpd -HUP

killall php -HUP
RETVAL=$?
echo
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
fi
;;
reload)
reload
;;
status)
status $lighttpd
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
RETVAL=1
esac

exit $RETVAL

8.PHPの動作確認

1)起動する
@Slackware10の場合
# /etc/rc.d/rc.lighttpd start

ANature's Linux1.3の場合
# /etc/init.d/lighttpd start

2)プロセス確認

# ps -ef
省略
nobody 2369 1 0 14:32 ? 00:00:00 /usr/sbin/lighttpd -f /usr/local/etc/lighttpd.conf
nobody 2370 2369 0 14:32 ? 00:00:00 /usr/local/bin/php-cgi
nobody 2371 2370 0 14:32 ? 00:00:00 /usr/local/bin/php-cgi
nobody 2374 2369 0 14:32 ? 00:00:00 /usr/local/bin/php-cgi
nobody 2375 2374 0 14:32 ? 00:00:00 /usr/local/bin/php-cgi
nobody 2376 2369 0 14:32 ? 00:00:00 /usr/local/bin/php-cgi
nobody 2377 2376 0 14:32 ? 00:00:00 /usr/local/bin/php-cgi
nobody 2378 2369 0 14:32 ? 00:00:00 /usr/local/bin/php-cgi
nobody 2379 2378 0 14:32 ? 00:00:00 /usr/local/bin/php-cgi
nobody 2380 2369 0 14:32 ? 00:00:00 /usr/local/sbin/cronolog /usr/local/apache/logs/access_log
root 2382 2140 0 14:33 pts/1 00:00:00 ps -ef

3)PHPの動作確認
phpinfo.phpを作ってPHPの動作確認。


  図1

9.その他
1) バナー情報の比較
参考までに、apacheとのバナー情報の比較を以下に示す。見てもらえれば解るが、情報が少し異なっている。

以下は、lighttpdのデフォルト設定のバナー情報。

root@slack10:~# telnet www.kozupon.com http
Trying 203.141.144.180...
Connected to www.kozupon.com.
Escape character is '^]'.

GET / HTTP/1.0  ← 入力
<リターン>

HTTP/1.0 400 Bad Request
Connection: close
Content-Type: text/html
Content-Length: 349
Date: Thu, 27 Apr 2006 01:24:46 GMT
Server: lighttpd/1.4.11

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>400 - Bad Request</title>
</head>
<body>
<h1>400 - Bad Request</h1>
</body>
</html>
Connection closed by foreign host.

以下は、apacheのバナー情報。httpd.confのServerTokensセクションはosレベルに設定されている。

root@slack10:~# telnet www.xxxxxxxxxxxx.co.jp http
Trying 210.196.76.153...
Connected to www.xxxxxxxxxxxx.co.jp.
Escape character is '^]'.

GET / HTTP/1.0  ← 入力
<リターン>

HTTP/1.1 400 Bad Request
Date: Thu, 27 Apr 2006 00:57:31 GMT
Server: Apache/2.0.52 (White Box)
Content-Length: 320
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.0.52 (White Box) Server at www.xxxxxxxxxxxx.co.jp Port 80</address>
</body></html>
Connection closed by foreign host.

2) 注意した方が良いこと
バグ等のパッチ処理として、phpのバージョンの最新ソースをインストールしたい場合は、lighttpdのソースも最新のものにしないと上手く動かないときがあるので、バージョンの整合性には注意すること。

■ DebianGNU/Linux4.0 etch編( LightTPD + PHP + Postgresql連携 )
DebianGNU/Linux4.0 etchのバイナリでlighttpdをインスコしてみた結果を掲載するlighttpdの他に以下をプラグインしてインスコ。
lighttpd+Postgresql7+PHP4

1.aptでパッケージダウンロードインスコ
wirehork:/# apt-get update

Get:1 http://ftp.dti.ad.jp etch Release.gpg [378B]
Hit http://ftp.dti.ad.jp etch Release
Ign http://ftp.dti.ad.jp etch/main Packages/DiffIndex
Ign http://ftp.dti.ad.jp etch/main Sources/DiffIndex
Hit http://ftp.dti.ad.jp etch/main Packages
Hit http://ftp.dti.ad.jp etch/main Sources
Get:2 http://security.debian.org etch/updates Release.gpg [189B]
Get:3 http://security.debian.org etch/updates Release [22.5kB]
Ign http://security.debian.org etch/updates/main Packages/DiffIndex
Ign http://security.debian.org etch/updates/contrib Packages/DiffIndex
Ign http://security.debian.org etch/updates/main Sources/DiffIndex
Ign http://security.debian.org etch/updates/contrib Sources/DiffIndex
Get:4 http://security.debian.org etch/updates/main Packages [113kB]
Hit http://security.debian.org etch/updates/contrib Packages
Get:5 http://security.debian.org etch/updates/main Sources [14.4kB]
Hit http://security.debian.org etch/updates/contrib Sources
Fetched 150kB in 3s (46.5kB/s)
Reading package lists... Done

wirehork:/# apt-get install php4 php4-common php4-cgi php4-pgsql postgresql libpcre3 zlib1g lighttpd lighttpd-doc

2.lighttpd.confの編集
wirehork:/# cd /etc/lighttpd

wirehork:/etc/lighttpd# vi lighttpd.conf
server.modules = (
              "mod_access",
              "mod_setenv",
              "mod_auth",
              "mod_ssi",
              "mod_alias",
              "mod_accesslog",
              "mod_rewrite",
              "mod_redirect",
              "mod_status",
              "mod_evhost",
              "mod_compress",
              "mod_accesslog",
              "mod_fastcgi"
)

server.document-root = "/var/www/"

server.errorlog = "/var/log/lighttpd/error.log"

index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" )


accesslog.filename = "/var/log/lighttpd/access.log"

url.access-deny = ( "~", ".inc" )

#server.port = 80

server.error-handler-404 = "/404.html"

server.pid-file = "/var/run/lighttpd.pid"

dir-listing.encoding = "utf-8"
server.dir-listing = "enable"

server.username = "www-data"

server.groupname = "www-data"

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

$HTTP["remoteip"] =~ "127.0.0.1" {
alias.url += (
"/doc/" => "/usr/share/doc/",
"/images/" => "/usr/share/images/"
)
$HTTP["url"] =~ "^/doc/|^/images/" {
dir-listing.activate = "enable"
}
}

include_shell "/usr/share/lighttpd/create-mime.assign.pl"

include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

ssi.extension = ( ".shtml" )

3.起動スクリプトを覗く
wirehork:/etc/lighttpd# more /etc/init.d/lighttpd

#!/bin/sh
### BEGIN INIT INFO
# Provides: lighttpd
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the lighttpd web server.
### END INIT INFO


PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/lighttpd
NAME=lighttpd
DESC="web server"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

DAEMON_OPTS="-f /etc/lighttpd/lighttpd.conf"

test -x $DAEMON || exit 0

set -e

. /lib/lsb/init-functions

case "$1" in
start)
log_daemon_msg "Starting $DESC" $NAME
if ! start-stop-daemon --start --quiet\
--pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then
log_end_msg 1
else
log_end_msg 0
fi
;;
stop)
log_daemon_msg "Stopping $DESC" $NAME
if start-stop-daemon --quiet --stop --oknodo --retry 30\
--pidfile $PIDFILE --exec $DAEMON; then
rm -f $PIDFILE
log_end_msg 0
else
log_end_msg 1
fi
;;
reload)
log_daemon_msg "Reloading $DESC configuration" $NAME
if start-stop-daemon --stop --signal 2 --oknodo --retry 30\
--quiet --pidfile $PIDFILE --exec $DAEMON; then
if start-stop-daemon --start --quiet \
--pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then
log_end_msg 0
else
log_end_msg 1
fi
else
log_end_msg 1
fi
;;
restart|force-reload)
$0 stop
[ -r $PIDFILE ] && while pidof lighttpd |\
grep -q `cat $PIDFILE 2>/dev/null` 2>/dev/null ; do sleep 1; do
ne
$0 start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac

exit 0

4.phpinfo画面の表示
インスコ後、phpinfo画面を表示させる。


  図2

■ CentOS 5 編(lighttpd + php + mysql連携)

lighttpd+php+mysqlをCentOSのバイナリでセットアップする場合、気をつけなければならないことは、fastcgiを使うためにphpをリビルドしなければならないことだ。具体的には、src.rpmファイルをダウンロードして.specファイルを編集(--enable-fastcgi --enable-discard-pathパラメータを追加して不要なパラメータを消す)して、rpmrebuildコマンドで、リビルドする。俺、個人としては非常に面倒だしリスクを伴うと思う。したがって、CentOSでlighttpd+php連携を行うには、個人的にはlighttpd(バイナリ) + php(ソース) + mysql(ソース)の構成がセットアップの容易さでもベストだと考える。ここでは、この構成で説明する。

注:
この説明の中で、mysqlは ここ を参考にしてあらかじめインストールされているものとして説明する。

1.lighttpdバイナリをインスコ
まず、lighttpdとfastcgiをyumで簡単インストールしよう。yumのアップデートを調べる。
[root@note ~]# yum check-update

アップデートが有れば、
[root@note ~]# yum update

lighttpdとfastcgiをインストールする。
[root@note ~]# yum install lighttpd lighttpd-fastcgi
Loading "fastestmirror" plugin
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Loading mirror speeds from cached hostfile
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for lighttpd to pack into transaction set.
lighttpd-1.4.18-1.el5.rf. 100% |=========================| 17 kB 00:00
---> Package lighttpd.i386 0:1.4.18-1.el5.rf set to be updated
---> Downloading header for lighttpd-fastcgi to pack into transaction set.
lighttpd-fastcgi-1.4.18-1 100% |=========================| 4.4 kB 00:00
---> Package lighttpd-fastcgi.i386 0:1.4.18-1.el5.rf set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
lighttpd i386 1.4.18-1.el5.rf dag 1.1 M
lighttpd-fastcgi i386 1.4.18-1.el5.rf dag 81 k

Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): lighttpd-1.4.18-1. 100% |=========================| 1.1 MB 00:35
(2/2): lighttpd-fastcgi-1 100% |=========================| 81 kB 00:01
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: lighttpd ######################### [1/2]
Installing: lighttpd-fastcgi ######################### [2/2]

Installed: lighttpd.i386 0:1.4.18-1.el5.rf lighttpd-fastcgi.i386 0:1.4.18-1.el5.rf
Complete!

2.logローテーションを行うcronologをインスコする
[root@note ~]# yum install cronolog

Loading "fastestmirror" plugin
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Loading mirror speeds from cached hostfile
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for cronolog to pack into transaction set.
cronolog-1.6.2-1.el5.rf.i 100% |=========================| 4.0 kB 00:00
---> Package cronolog.i386 0:1.6.2-1.el5.rf set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
cronolog i386 1.6.2-1.el5.rf dag 34 k

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 34 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): cronolog-1.6.2-1.e 100% |=========================| 34 kB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: cronolog ######################### [1/1]

Installed: cronolog.i386 0:1.6.2-1.el5.rf
Complete!

phpをインストールするときに使うzlibとlibxmlをインストールする。

3.phpのインスコ
phpで使うzlibとlibxml2をインスコする
[root@note ~]# yum install libxml2-devel zlib

phpのソースをwgetして、ビルドする。
[root@note ~]# cd /usr/local/src/
[root@note src]# wget http://jp.php.net/get/php-5.2.4.tar.gz/from/this/mirror
[root@note src]# tar zxvf php-5.2.4.tar.gz
[root@note src]# chown -R root.root php-5.2.4
[root@note src]# cd php-5.2.4

mysqlとfastcgiを組み込むためのMakefileを作るには、以下のフルパラメータでconfigureを行う。
[root@note php-5.2.4]# ./configure --enable-fastcgi --enable-discard-path --enable-force-cgi-redirect --enable-mbstring --enable-mbregex --enable-mbstr-enc-trans --enable-iconv --with-mysql=/usr/local/mysql --with-zlib
[root@note php-5.2.4]# make
[root@note php-5.2.4]# make install

念のため、開発環境も整備しておこう。
[root@note ~]# yum install gcc-c++ gcc-java gcc-objc gcc4 gcc4-c++ autoconf libtool automake bison flex ncurses-devel

4.lighttpdを設定する
lighttpdの設定ファイルをカスタマイズする。ここでは、phpを使える環境に設定している。
[root@note ~]# vi /etc/lighttpd/lighttpd.conf

server.modules = (
             "mod_fastcgi",
             "mod_cgi",
             "mod_rewrite",
             "mod_access",
             "mod_auth",
             "mod_setenv",
             "mod_userdir",
             "mod_simple_vhost",
             "mod_alias",
             # "mod_dirlisting",                          
←serverモジュールにこれが無いようだ、エラーになる。
             "mod_accesslog" )

server.document-root = "/var/www/"

userdir.path = "public_html"

# userdir.basepath = "/home/"                              ←このパラメータの記述では、エラーが出る。

alias.url = (
        "/cgi-bin/" => "/var/cgi-bin/",
        "/icons/" => "/var/icons/"
)

server.errorlog = "/var/log/lighttpd/error_log"


$HTTP["url"] =~"/download" {
                    dir-listing.activate = "enable"
}

# index-file.names = ( "index.php", "index.html",
#           "index.htm", "default.htm",
#           "index.cgi", "index.pl" )

server.indexfiles = ( "index.php", "index.html",                   ←indexファイル定義のパラメータが、これでないとエラーが出る。
              "index.htm", "default.htm",
              "index.cgi", "index.pl",
              "index.php4", "index.php3" )

mimetype.assign = (
               ".pdf" => "application/pdf",
               ".sig" => "application/pgp-signature",
               ".spl" => "application/futuresplash",
               ".class" => "application/octet-stream",
               ".ps" => "application/postscript",
               ".torrent" => "application/x-bittorrent",
               ".dvi" => "application/x-dvi",
               ".gz" => "application/x-gzip",
               ".pac" => "application/x-ns-proxy-autoconfig",
               ".swf" => "application/x-shockwave-flash",
               ".tar.gz" => "application/x-tgz",
               ".tgz" => "application/x-tgz",
               ".tar" => "application/x-tar",
               ".zip" => "application/zip",
               ".mp3" => "audio/mpeg",
               ".m3u" => "audio/x-mpegurl",
               ".wma" => "audio/x-ms-wma",
               ".wax" => "audio/x-ms-wax",
               ".ogg" => "application/ogg",
               ".wav" => "audio/x-wav",
               ".gif" => "image/gif",
               ".jpg" => "image/jpeg",
               ".jpeg" => "image/jpeg",
               ".png" => "image/png",
               ".xbm" => "image/x-xbitmap",
               ".xpm" => "image/x-xpixmap",
               ".xwd" => "image/x-xwindowdump",
               ".css" => "text/css",
               ".html" => "text/html",
               ".htm" => "text/html",
               ".js" => "text/javascript",
               ".asc" => "text/plain",
               ".c" => "text/plain",
               ".cpp" => "text/plain",
               ".log" => "text/plain",
               ".conf" => "text/plain",
               ".text" => "text/plain",
               ".txt" => "text/plain",
               ".dtd" => "text/xml",
               ".xml" => "text/xml",
               ".mpeg" => "video/mpeg",
               ".mpg" => "video/mpeg",
               ".mov" => "video/quicktime",
               ".qt" => "video/quicktime",
               ".avi" => "video/x-msvideo",
               ".asf" => "video/x-ms-asf",
               ".asx" => "video/x-ms-asf",
               ".wmv" => "video/x-ms-wmv",
               ".bz2" => "application/x-bzip",
               ".tbz" => "application/x-bzip-compressed-tar",
               ".tar.bz2" => "application/x-bzip-compressed-tar"
)

accesslog.filename = "|/usr/sbin/cronolog /var/log/lighttpd/access_log.%Y%m%d"

server.port = 7000

accesslog.format = "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""

server.error-handler-404 = "/404.html"

server.pid-file = "/var/run/lighttpd.pid"

server.username = "nobody"

server.groupname = "nobody"

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

cgi.assign = ( ".pl" => "/usr/bin/perl",".cgi" => "/usr/bin/perl" )

5.起動する
起動ファイルを覗く。

[root@note ~]# cd /etc/init.d/
[root@note init.d]# more lighttpd
#!/bin/sh
#
# lighttpd Startup script for the lighttpd server
#
# chkconfig: - 85 15
# description: Lightning fast webserver with light system requirements
#
# processname: lighttpd
# config: /etc/lighttpd/lighttpd.conf
# config: /etc/sysconfig/lighttpd
# pidfile: /var/run/lighttpd.pid
#
# Note: pidfile is assumed to be created
# by lighttpd (config: server.pid-file).
# If not, uncomment 'pidof' line.

# Source function library
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/lighttpd ]; then
. /etc/sysconfig/lighttpd
fi

if [ -z "$LIGHTTPD_CONF_PATH" ]; then
LIGHTTPD_CONF_PATH="/etc/lighttpd/lighttpd.conf"
fi

prog="lighttpd"
lighttpd="/usr/sbin/lighttpd"
RETVAL=0

start() {
echo -n $"Starting $prog: "
daemon $lighttpd -f $LIGHTTPD_CONF_PATH
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
killproc $lighttpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}

reload() {
echo -n $"Reloading $prog: "
killproc $lighttpd -HUP
RETVAL=$?
echo
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
fi
;;
reload)
reload
;;
status)
status $lighttpd
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
RETVAL=1
esac

exit $RETVAL

lighttpdを起動する。
[root@note init.d]# ./lighttpd start
Starting lighttpd: [ OK ]

その他各ディストリビューションインストール編


◆ 簡単モジュール説明

■ mod_accesslog
アクセスログを使う。

使い方(何れも cronolog でログのローティションを行う例):
* バーチャルホストとして設定する場合、

accesslog.filename = "/var/log/lighttpd.log"
$HTTP["host"] == "mail.example.org" {
             accesslog.filename = "|/usr/bin/cronolog"
}

* 通常の場合、
accesslog.filename = "|/usr/local/sbin/cronolog /usr/local/apache/logs/access_log.%Y%m%d"
%Y%m%dは、年号と日付が入る。

■ mod_access
読み分け記号(~)で終わったすべてのファイルへのアクセスもしくは~や.incなどで例えば、example.incを拒否するでしょう。 ~のような読み分け記号はバックアップファイルにしばしばエディタによって使用されます。 そして、.inc拡張子はインクルードファイルにしばしばコードで使用されます。このように、拒否したい拡張子のファイルなどを定義したいときは便利です。

使い方:
url.access-deny = ( "~", ".inc")

■ mod_alias
ディレクトリエーリアス。

使い方:
alias.url = ( "/cgi-bin/" => "/var/www/servers/www.example.org/cgi-bin/" )

■ mod_cgi
CGIを使う。

使い方:
cgi.assign = ( ".pl" => "/usr/bin/perl",
         ".cgi" => "/usr/bin/perl" )

■ mod_compress
アウトプット圧縮。

使い方:
* 通常の場合
compress.cache-dir = "/var/www/cache/"
compress.filetype = ("text/plain", "text/html")

* バーチャルホストとしての定義
$HTTP["host"] == "docs.example.org" {
             compress.cache-dir = "/var/www/cache/docs.example.org/"
}

compress.filetype = ("text/plain", "text/html")

■ mod_dirlisting
Apacheで言うディレクトリインデックス。ディレクトリリスト表示。

使い方:
dir-listing.activate = "enable"

$HTTP["url"] =~ "^/download($|/)" {
            dir-listing.activate = "enable"
}

index-file.names = ( "/dir-generator.php" )

■ mod_evhost
ワイルドカードを含むパターンに基づくドキュメントルートを作る。 それらのワイルドカードが出力されたホスト名であるなら部品を表すことができる。

使い方:
%% => % sign
%0 => domain name + tld
%1 => tld
%2 => domain name without tld
%3 => subdomain 1 name
%4 => subdomain 2 name

evhost.path-pattern = "/home/www/servers/%3/pages/"

■ mod_expire
HTTP/1.0のメッセージのResponse HeaderでExpireヘッダーを監視する。

expire.url = ( "/images/" => "access 1 hour" )

■ mod_fastcgi
CGI版スクリプトを指定する。lighttpdは、CGI経由で色々なスクリプトを実行する構造になってる。したがって、以下の例のようにPHPもCGI経由で実行される。

使い方:
以下はCGI経由のPHPを定義している。
fastcgi.server = ( ".php" =>
           ( "localhost" =>
            (
             "socket" => "/tmp/php-fastcgi.socket",
             "bin-path" => "/usr/local/bin/php"
            )
           ),
           ".php4" =>
           ( "localhost" =>
            (
             "socket" => "/tmp/php-fastcgi.socket",
             "bin-path" => "/usr/local/bin/php"
            )
           ),
           ".php3" =>
           ( "localhost" =>
            (
             "socket" => "/tmp/php-fastcgi.socket",
             "bin-path" => "/usr/local/bin/php"
            )
           )
          )

■ mod_mysql_vhost
MySQLベースのvhostingで、あなたはMySQLデータベースの与えられたホストのドキュメントルートとして経路を保存することができる。

使い方:
mysql-vhost.db = "lighttpd"
mysql-vhost.user = "lighttpd"
mysql-vhost.pass = "secret"
mysql-vhost.sock = "/var/mysql.lighttpd.sock"
mysql-vhost.sql = "SELECT docroot FROM domains WHERE domain='?'"

MySQL setup:
mysql> GRANT SELECT ON lighttpd.* TO lighttpd@localhost IDENTIFIED BY 'secret';

mysql> CREATE DATABASE lighttpd;

mysql> USE lighttpd;

mysql> CREATE TABLE domains ( domain varchar(64) not null primary key, docroot varchar(128) not null );

mysql> INSERT INTO domains VALUES ('host.dom.ain','/http/host.dom.ain/');

■ mod_proxy
lighttpdでHTTPインタフェースを持っているjavaサーバに接続するプロキシモジュールの最も簡単な方法。

使い方:
$HTTP["host"] == "www.example.org" {

proxy.balance = "hash"
proxy.server = ( "" => ( ( "host" => "10.0.0.10" ),
                ( "host" => "10.0.0.11" ),
                ( "host" => "10.0.0.12" ),
                ( "host" => "10.0.0.13" ),
                ( "host" => "10.0.0.14" ),
                ( "host" => "10.0.0.15" ),
                ( "host" => "10.0.0.16" ),
                ( "host" => "10.0.0.17" ) ) )

■ mod_redirect
外部の直接リダイレクトしたいURLを設定する。

使い方:
url.redirect = ( "^/show/([0-9]+)/([0-9]+)$" => "http://www.example.org/show.php?isdn=$1&page$2",
"^/get/([0-9]+)/([0-9]+)$" => "http://www.example.org/get.php?isdn=$1&page$2" )

$HTTP["host"] =~ "^www\.(.*)" {
url.redirect = ( "^/(.*)" => "http://%1/$1" )
}

■ mod_rewrite
アクセスするURLを正規表現で書き換える。

使い方:
url.rewrite-once = ( "^/id/([0-9]+)$" => "/index.php?id=$1",
"^/link/([a-zA-Z]+)" => "/index.php?link=$1" )

server.document-root = "/www/htdocs/"
$HTTP["host"] =~ "^.*\.([^.]+\.com)$" {
url.rewrite-once = ( "^/(.*)" => "/%0/$1" )
}

■ mod_rrdtool
RRDツールを使う。
RRDは保存するシステムとディスプレイ時系列データ(すなわち、ネットワーク帯域幅、印刷室温度、サーバ負荷平均)である。

使い方:
rrdtool.binary = "/usr/bin/rrdtool"
rrdtool.db-name = "/var/www/lighttpd.rrd"

■ mod_scgi
SCGIは速くて簡易型のCGIインタフェースです。

■ mod_secdownload
深いリンクに反対する認証されているファイル要求の対策は、mod_secdownloadを使って容易に達成できます。さらに、ダウンロードを高速に行えます。

使い方:
secdownload.secret = <string>
secdownload.document-root = <string>
secdownload.uri-prefix = <string> (default: /)
secdownload.timeout = <short> (default: 60 seconds)

■ mod_setenv
リクエストを分割する機能を提供します。

使い方:
setenv.add-environment
adds a value to the process environment that is passed to the external applications
setenv.add-response-header
adds a header to the HTTP response sent to the client
setenv.add-request-header
adds a header to the HTTP request that was received from the client

■ mod_simple_vhost
簡易バーチャルホスト定義。

使い方:
simple-vhost.server-root = "/var/www/servers/"
simple-vhost.default-host = "www.example.org"
simple-vhost.document-root = "pages"

$HTTP["host"] == "news.example.org" {
server.document-root = "/var/www/servers/news2.example.org/pages/"
}


■ mod_ssi
サーバサイドインクルード。Apache SSIとコンパチブルレイヤーを提供します。

使い方:
server.modules = ( ..., "mod_ssi", ... )
ssi.extension = ( ".shtml" )

■ mod_status
mod_statusはサーバーのステータスとコンフィギュレーションを表示します。

使い方:
* mod_statusを使うためにモジュールをロードする。
server.modules = ( ..., "mod_status", ... )

* デフォルトで、ステータスページは、未認証のユーザーから内部の情報を隠すために使用不可にされます。
status.status-url = "/server-status"

* ローカルIPからステータスページを開きたい場合は、
$HTTP["remoteip"] == "10.0.0.0/8" {
                status.status-url = "/server-status"
}

■ mod_auth
auth.require = ( "/server-status" =>
          ( "realm" ... ) )

* 認証を必要とする場合(Digest認証)
この説明では、 Document root/hoge ディレクトリへ認証を掛けることを前提としている。
# htdigest -c /usr/local/etc/lighttpd.user.htdigest hoge
Adding password for secret in realm Security Zone.

New password:                            ←ユーザー認証用のパスワードを入力
Re-type new password:                      ←ユーザー認証用のパスワードを再入力

lighttpdの設定ファイル( /usr/local/etc/lighttpd.conf )を変更する。
server.modules = (
省略
"mod_auth",
省略
"mod_accesslog" )

以下の記述を適当な場所に追加する。ここでは、ユーザー認証によるアクセス制限をかけるディレクトリを/usr/local/apache/htdocs/hogeとしている。
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/usr/local/etc/lighttpd.user.htdigest"
auth.require = ( "/hoge/" =>          ←ユーザー認証が必要なディレクトリ
               (
"method" => "digest",

"realm" => "Security Zone",          ←htdigestコマンドで指定したレルム
"require" => "valid-user"             ←"user=hoge"とすると、ユーザーを限定可能
              )
          )

* 認証を必要とする場合(Basict認証)
この説明では、 Document root/hoge ディレクトリへ認証を掛けることを前提としている。
# htpasswd -c /usr/local/etc/lighttpd.user.basic hoge
Adding password for secret in realm Security Zone.

New password:                            ←ユーザー認証用のパスワードを入力
Re-type new password:                      ←ユーザー認証用のパスワードを再入力

lighttpdの設定ファイル( /usr/local/etc/lighttpd.conf )を変更する。
server.modules = (
省略
"mod_auth",
省略
"mod_accesslog" )

以下の記述を適当な場所に追加する。ここでは、ユーザー認証によるアクセス制限をかけるディレクトリを/usr/local/apache/htdocs/hogeとしている。
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/usr/local/etc/lighttpd.user.basic"
auth.require = ( "/hoge/" =>          ←ユーザー認証が必要なディレクトリ
               (
"method" => "basic",

"realm" => "Security Zone",          ←htpasswdコマンドで指定したレルム
"require" => "valid-user"             ←"user=hoge"とすると、ユーザーを限定可能
              )
          )

lighttpd.confの変更が終わったら、lighttpdを再起動する。

■ mod_trigger_b4_dl

使い方:
trigger-before-download.gdbm-filename = "/home/weigon/testbase/trigger.db"
trigger-before-download.memcache-hosts = ( "127.0.0.1:11211" )
trigger-before-download.trigger-url = "^/trigger/"
trigger-before-download.download-url = "^/download/"
trigger-before-download.deny-url = "http://192.168.1.5:1025/index.html"
trigger-before-download.trigger-timeout = 10

■ mod_userdir
ユーザサイトを定義する。

使い方:
* ユーザ公開ディレクトリ名
userdir.path = "public_html"

* ユーザ公開ディレクトリパス(通常は、 /home/ で良いと思う)
userdir.basepath = "/home/users/"


■ mod_webdav
webdavを使う。

使い方:
$HTTP["url"] =~ "^/dav($|/)" {
webdav.activate = "enable"
webdav.is-readonly = "enable"
}


◆ メーリングリスト

準備中


lighttpd was made by lighttpd.net .
As for the Japanese site of lighttpd made it. 


Copyright 2005-2007 Kozupon.com.