ラズパイでLighttpd
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
* ラズパイでLighttpd [#fe239343]
ラズパイにHTTPサーバを導入するなら[[Lighttpd:https://www....
$ sudo apt install lighttpd
たったこれだけで導入完了。
設定ファイル等は
$ tree /etc/lighttpd/
/etc/lighttpd/
├── conf-available
│ ├── 05-auth.conf
│ ├── 05-setenv.conf
│ ├── 10-accesslog.conf
│ ├── 10-cgi.conf
│ ├── 10-dir-listing.conf
│ ├── 10-evasive.conf
│ ├── 10-evhost.conf
│ ├── 10-expire.conf
│ ├── 10-fastcgi.conf
│ ├── 10-flv-streaming.conf
│ ├── 10-no-www.conf
│ ├── 10-proxy.conf
│ ├── 10-rewrite.conf
│ ├── 10-rrdtool.conf
│ ├── 10-simple-vhost.conf
│ ├── 10-sockproxy.conf
│ ├── 10-ssi.conf
│ ├── 10-ssl.conf
│ ├── 10-status.conf
│ ├── 10-userdir.conf
│ ├── 10-usertrack.conf
│ ├── 11-extforward.conf
│ ├── 15-fastcgi-php.conf
│ ├── 15-fastcgi-php-fpm.conf
│ ├── 20-deflate.conf
│ ├── 90-debian-doc.conf
│ ├── 99-unconfigured.conf
│ └── README
├── conf-enabled
│ └── 99-unconfigured.conf -> ../conf-available/99-unc...
└── lighttpd.conf
というような構成になっている。
メインの設定は
$ cat /etc/lighttpd/lighttpd.conf
server.modules = (
"mod_indexfile",
"mod_access",
"mod_alias",
"mod_redirect",
)
server.document-root = "/var/www/html"
server.upload-dirs = ( "/var/cache/lighttpd/upl...
server.errorlog = "/var/log/lighttpd/error.l...
server.pid-file = "/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80
# features
#https://redmine.lighttpd.net/projects/lighttpd/wiki/Ser...
server.feature-flags += ("server.h2proto" => "enab...
server.feature-flags += ("server.h2c" => "enab...
server.feature-flags += ("server.graceful-shutdown...
#server.feature-flags += ("server.graceful-restart...
# strict parsing and normalization of URL for consistenc...
# https://redmine.lighttpd.net/projects/lighttpd/wiki/Se...
# (might need to explicitly set "url-path-2f-decode" = "...
# if a specific application is encoding URLs inside url...
server.http-parseopts = (
"header-strict" => "enable",# default
"host-strict" => "enable",# default
"host-normalize" => "enable",# default
"url-normalize-unreserved"=> "enable",# recommended hi...
"url-normalize-required" => "enable",# recommended
"url-ctrls-reject" => "enable",# recommended
"url-path-2f-decode" => "enable",# recommended hi...
#"url-path-2f-reject" => "enable",
"url-path-dotseg-remove" => "enable",# recommended hi...
#"url-path-dotseg-reject" => "enable",
#"url-query-20-plus" => "enable",# consistency in...
)
index-file.names = ( "index.php", "index.html...
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi...
# default listening port for IPv6 falls back to the IPv4...
include_shell "/usr/share/lighttpd/use-ipv6.pl " + serve...
include_shell "/usr/share/lighttpd/create-mime.conf.pl"
include "/etc/lighttpd/conf-enabled/*.conf"
#server.compat-module-load = "disable"
server.modules += (
"mod_dirlisting",
"mod_staticfile",
)
と非常に少なめでシンプル。
細かい設定等は[[Wiki:https://redmine.lighttpd.net/project...
** CGIを有効にする [#bd70d662]
もし、CGIを利用したいなら
$ sudo lighttpd-enable-mod cgi
CGIの設定は、下記のファイルになる。
$ cat /etc/lighttpd/conf-available/10-cgi.conf
# /usr/share/doc/lighttpd/cgi.txt
server.modules += ( "mod_cgi" )
$HTTP["url"] =~ "^/cgi-bin/" {
cgi.assign = ( "" => "" )
alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/...
}
## Warning this represents a security risk, as it allow ...
## with a .pl/.py even outside of /usr/lib/cgi-bin.
#
#cgi.assign = (
# ".pl" => "/usr/bin/perl",
# ".py" => "/usr/bin/python",
#)
当然、これをこのまま動かしてもダメ。~
cgi.assign に有効にしたい拡張子とコマンドを設定する。
# /usr/share/doc/lighttpd/cgi.txt
server.modules += ( "mod_cgi" )
$HTTP["url"] =~ "^/cgi-bin/" {
cgi.assign = ( ".py" => "/usr/bin/python" )
alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/" )
}
## Warning this represents a security risk, as it allow ...
## with a .pl/.py even outside of /usr/lib/cgi-bin.
#
#cgi.assign = (
# ".pl" => "/usr/bin/perl",
# ".py" => "/usr/bin/python",
#)
pythonを利用した場合には、上記のように設定する。
あとは、再起動して有効にする。
$ sudo service lighttpd force-reload
** FastCGIを有効にする [#r9dc5e70]
PHPなどを使用する場合などはFastCGIを有効にすると良い。
$ sudo lighttpd-enable-mod fastcgi
$ sudo lighttpd-enable-mod fastcgi-php
FastCGIの設定は、下記の2つのファイルになる。
$ cat /etc/lighttpd/conf-available/10-fastcgi.conf
# /usr/share/doc/lighttpd/fastcgi.txt.gz
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Doc...
server.modules += ( "mod_fastcgi" )
それと
$ cat /etc/lighttpd/conf-available/15-fastcgi-php.conf
# -*- depends: fastcgi -*-
# /usr/share/doc/lighttpd/fastcgi.txt.gz
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Doc...
## Start an FastCGI server for php (needs the php-cgi pa...
fastcgi.server += ( ".php" =>
((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/run/lighttpd/php.socket",
"max-procs" => 1,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "10000"
),
"bin-copy-environment" => (
"PATH", "SHELL", "USER"
),
"broken-scriptfilename" => "enable"
))
)
FPMを利用したい場合は、fastcgi-php-fpm を利用(今回は省略)。
あとは、再起動して有効にする。
$ sudo service lighttpd force-reload
** あると便利なアクセスログ [#habcda38]
あると便利なアクセスログは下記で有効にできる。
$ sudo lighttpd-enable-mod accesslog
~
※Raspberry PiはRaspberry Pi財団の登録商標です。
#htmlinsert(rpi3b+.html);
終了行:
* ラズパイでLighttpd [#fe239343]
ラズパイにHTTPサーバを導入するなら[[Lighttpd:https://www....
$ sudo apt install lighttpd
たったこれだけで導入完了。
設定ファイル等は
$ tree /etc/lighttpd/
/etc/lighttpd/
├── conf-available
│ ├── 05-auth.conf
│ ├── 05-setenv.conf
│ ├── 10-accesslog.conf
│ ├── 10-cgi.conf
│ ├── 10-dir-listing.conf
│ ├── 10-evasive.conf
│ ├── 10-evhost.conf
│ ├── 10-expire.conf
│ ├── 10-fastcgi.conf
│ ├── 10-flv-streaming.conf
│ ├── 10-no-www.conf
│ ├── 10-proxy.conf
│ ├── 10-rewrite.conf
│ ├── 10-rrdtool.conf
│ ├── 10-simple-vhost.conf
│ ├── 10-sockproxy.conf
│ ├── 10-ssi.conf
│ ├── 10-ssl.conf
│ ├── 10-status.conf
│ ├── 10-userdir.conf
│ ├── 10-usertrack.conf
│ ├── 11-extforward.conf
│ ├── 15-fastcgi-php.conf
│ ├── 15-fastcgi-php-fpm.conf
│ ├── 20-deflate.conf
│ ├── 90-debian-doc.conf
│ ├── 99-unconfigured.conf
│ └── README
├── conf-enabled
│ └── 99-unconfigured.conf -> ../conf-available/99-unc...
└── lighttpd.conf
というような構成になっている。
メインの設定は
$ cat /etc/lighttpd/lighttpd.conf
server.modules = (
"mod_indexfile",
"mod_access",
"mod_alias",
"mod_redirect",
)
server.document-root = "/var/www/html"
server.upload-dirs = ( "/var/cache/lighttpd/upl...
server.errorlog = "/var/log/lighttpd/error.l...
server.pid-file = "/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80
# features
#https://redmine.lighttpd.net/projects/lighttpd/wiki/Ser...
server.feature-flags += ("server.h2proto" => "enab...
server.feature-flags += ("server.h2c" => "enab...
server.feature-flags += ("server.graceful-shutdown...
#server.feature-flags += ("server.graceful-restart...
# strict parsing and normalization of URL for consistenc...
# https://redmine.lighttpd.net/projects/lighttpd/wiki/Se...
# (might need to explicitly set "url-path-2f-decode" = "...
# if a specific application is encoding URLs inside url...
server.http-parseopts = (
"header-strict" => "enable",# default
"host-strict" => "enable",# default
"host-normalize" => "enable",# default
"url-normalize-unreserved"=> "enable",# recommended hi...
"url-normalize-required" => "enable",# recommended
"url-ctrls-reject" => "enable",# recommended
"url-path-2f-decode" => "enable",# recommended hi...
#"url-path-2f-reject" => "enable",
"url-path-dotseg-remove" => "enable",# recommended hi...
#"url-path-dotseg-reject" => "enable",
#"url-query-20-plus" => "enable",# consistency in...
)
index-file.names = ( "index.php", "index.html...
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi...
# default listening port for IPv6 falls back to the IPv4...
include_shell "/usr/share/lighttpd/use-ipv6.pl " + serve...
include_shell "/usr/share/lighttpd/create-mime.conf.pl"
include "/etc/lighttpd/conf-enabled/*.conf"
#server.compat-module-load = "disable"
server.modules += (
"mod_dirlisting",
"mod_staticfile",
)
と非常に少なめでシンプル。
細かい設定等は[[Wiki:https://redmine.lighttpd.net/project...
** CGIを有効にする [#bd70d662]
もし、CGIを利用したいなら
$ sudo lighttpd-enable-mod cgi
CGIの設定は、下記のファイルになる。
$ cat /etc/lighttpd/conf-available/10-cgi.conf
# /usr/share/doc/lighttpd/cgi.txt
server.modules += ( "mod_cgi" )
$HTTP["url"] =~ "^/cgi-bin/" {
cgi.assign = ( "" => "" )
alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/...
}
## Warning this represents a security risk, as it allow ...
## with a .pl/.py even outside of /usr/lib/cgi-bin.
#
#cgi.assign = (
# ".pl" => "/usr/bin/perl",
# ".py" => "/usr/bin/python",
#)
当然、これをこのまま動かしてもダメ。~
cgi.assign に有効にしたい拡張子とコマンドを設定する。
# /usr/share/doc/lighttpd/cgi.txt
server.modules += ( "mod_cgi" )
$HTTP["url"] =~ "^/cgi-bin/" {
cgi.assign = ( ".py" => "/usr/bin/python" )
alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/" )
}
## Warning this represents a security risk, as it allow ...
## with a .pl/.py even outside of /usr/lib/cgi-bin.
#
#cgi.assign = (
# ".pl" => "/usr/bin/perl",
# ".py" => "/usr/bin/python",
#)
pythonを利用した場合には、上記のように設定する。
あとは、再起動して有効にする。
$ sudo service lighttpd force-reload
** FastCGIを有効にする [#r9dc5e70]
PHPなどを使用する場合などはFastCGIを有効にすると良い。
$ sudo lighttpd-enable-mod fastcgi
$ sudo lighttpd-enable-mod fastcgi-php
FastCGIの設定は、下記の2つのファイルになる。
$ cat /etc/lighttpd/conf-available/10-fastcgi.conf
# /usr/share/doc/lighttpd/fastcgi.txt.gz
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Doc...
server.modules += ( "mod_fastcgi" )
それと
$ cat /etc/lighttpd/conf-available/15-fastcgi-php.conf
# -*- depends: fastcgi -*-
# /usr/share/doc/lighttpd/fastcgi.txt.gz
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Doc...
## Start an FastCGI server for php (needs the php-cgi pa...
fastcgi.server += ( ".php" =>
((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/run/lighttpd/php.socket",
"max-procs" => 1,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "10000"
),
"bin-copy-environment" => (
"PATH", "SHELL", "USER"
),
"broken-scriptfilename" => "enable"
))
)
FPMを利用したい場合は、fastcgi-php-fpm を利用(今回は省略)。
あとは、再起動して有効にする。
$ sudo service lighttpd force-reload
** あると便利なアクセスログ [#habcda38]
あると便利なアクセスログは下記で有効にできる。
$ sudo lighttpd-enable-mod accesslog
~
※Raspberry PiはRaspberry Pi財団の登録商標です。
#htmlinsert(rpi3b+.html);
ページ名: