Raspberry pi セットアップその11 WEBサーバをLighttpdに変更

1441

 

1. 概要

 
Lighttpdは軽量・高速なWEBサーバソフトです。これまで Apacheを使っていましたが、非力な piにはこちらのほうがよさそうです。軽量高速といっても機能は充分。これに変えたきっかけは、サーバサイドの2ちゃんねるビューワ rep2を Apacheで動作させると非力さゆえか connection timed outが頻発していたためでした。(2ちゃんねるといっても私は旅行系と食事系の板しか見ませんけどね……)。
 

2. インストール

 

[root@tembikai]:~# apt-get -y install lighttpd

 

3. 設定

 
設定は /etc/lighttpd/lighttpd.confにあります。debianでは /etc/lighttpd/conf-availableにサンプルがいくつもありますが、わかりづらいので
直接編集します。
 

[root@tembikai]:~# vi /etc/lighttpd/lighttpd.conf

 
サーバモジュールを設定します。rewrite, redirect, access, authは最初に書く必要があります。その次に cgi, ssi等の処理を、最後に log等の処理を書きます
 

server.modules = (
        "mod_rewrite",
        "mod_redirect",
        "mod_access",
        "mod_auth",
        "mod_cgi",
        "mod_ssi",
        "mod_alias",
        "mod_compress",
        "mod_fastcgi",
        "mod_accesslog",
)

 
DocumentRoot等を設定します。

server.document-root        = "/html/www"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80

 
fastcgiの設定をします。

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

 
SSIを使用したいので下記を追記します。

#### mod_ssi
ssi.extension              = ( ".shtml" )

 
これだけでは exec cmdを使ったページが 404 not found になってしまうので下記も設定します。

static-file.exclude-extensions = ( ".shtml", ".php", ".pl", ".fcgi" )

 
apacheを停止し、起動スクリプトを削除します。

[root@tembikai]:~# service apache2 stop
[root@tembikai]:~# rm /etc/rc.2d/*apache*

 
lighttpdを起動します

[root@tembikai]:~# service lighttpd restart

 
単純な処理であれば、apacheの倍近い速度がでるそうです。php処理についてのパフォーマンスは知りませんが、rep2も正常に動作するようになりました。
 
 

1件のピンバック

コメントは現在停止中です。