1 インストール
2 lighttpdでrubyのCGIを動作させるための設定
3 rubyのCGIサンプル
4 lighttpdのBASIC認証
apt-get install
lighttpd ruby |
static-file.exclude-extensions
= ( ".php", ".pl", ".fcgi", ".rb"
) |
cgi.assign
= ( # ".pl" => "/usr/bin/perl", # ".py" => "/usr/bin/python", ".rb" => "/usr/bin/ruby", ) |
lighty-enable-mod cgi |
/etc/init.d/lighttpd
restart |
#!/usr/bin/ruby -Ku #ヘッダー部 puts "Content-Type: text/html" puts #ここでひとつ改行コードを送る #body部 print <<"EOB" <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf8"> <title>Ruby!</title> </head> <body> <h3>Hello</h3> <p>これは、おためしサンプルです。</p> </body> </html> EOB |
hogehoge:パスワード |
# chown www-data
/etc/lighttpd/lighttpd.user # chgrp www-data /etc/lighttpd/lighttpd.user # chmod 600 www-data /etc/lighttpd/lighttpd.user |
#
/usr/share/doc/lighttpd/authentication.txt.gz server.modules += ( "mod_auth" ) auth.backend = "plain" auth.backend.plain.userfile = "/etc/lighttpd/lighttpd.user" # auth.backend.plain.groupfile = "lighttpd.group" # auth.backend.ldap.hostname = "localhost" # auth.backend.ldap.base-dn = "dc=my-domain,dc=com" # auth.backend.ldap.filter = "(uid=$)" auth.require = ( "/" => ( "method" => "basic", "realm" => "Secret", "require" => "valid-user" ) ) # auth.require = ( "/server-status" => # ( # "method" => "digest", # "realm" => "download archiv", # "require" => "group=www|user=jan|host=192.168.2.10" # ), # "/server-info" => # ( # "method" => "digest", # "realm" => "download archiv", # "require" => "group=www|user=jan|host=192.168.2.10" # ) # ) |
# lighty-enable-mod auth /etc/init.d/lighttpd restart |