lighttpdでローカルファイルを見る
- http://d.hatena.ne.jp/NeoCat/20080723/1216761818
- http://d.hatena.ne.jp/NeoCat/20080731
- http://kitta.jf.land.to/index.cgi?page=Diary%2F2008-07-24
を参考にlighttpdをiPhoneで動かしてみる。地下鉄通学だと電波が入らないので、ローカルでJ言語のPrimerを読めるようにしようと思い立った。
1.JB済みのiPhoneを用意
2.lighttpdをCydiaなりで入れる
3.設定ファイルを作成
/etc/lighttpd.conf
#modules server.modules = ( "mod_cgi", "mod_access", "mod_alias", ) cgi.assign = ( ".cgi" => "", ) # index server.document-root = "/private/var/mobile/Sites/" dir-listing.external-css = "/style.css" server.dir-listing = "enable" dir-listing.hide-dotfiles = "enable" dir-listing.encoding = "utf-8" index-file.names = ( "index.html", "index.htm", "index.cgi", "index.shtml" ) # mimetype mapping 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", ".jar" => "application/x-java-archive", ".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", ".mp4" => "video/quicktime", ".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", # default mime type "" => "application/octet-stream", ) # other settings server.port = 80 server.username = "nobody" server.groupname = "nobody" server.bind = "localhost" # for security reason
cssには、3番目のリンク先の人のをそのまま使わせていただく。
/private/var/mobile/Sites/style.css
body,table{ width:980px; } a,.n,.t{ height:150px;/* =* line-heigh */ } *{ line-height:150px;/* =a,.n,.t height */ font-size:48px; margin:0; padding:0; font-family: "Arial Unicode MS"; vertical-align:middle; font-weight:bold; text-decoration:none; background-color:#2e2e2e; /* =.n color */ } td{ display:block; overflow:hidden; border-bottom:5px solid #595959; } .n,.t{ float:left; } .n{ color:#2e2e2e; /* =background-color */ width:760px; } a{ color:#e5e5e5; width:740px; text-indent:40px; display:block; float:left; overflow:hidden; } .t{ font-size:35px; width:220px; color:#7f7f7f; } h2,th,.m,.s,.foot{ display:none; }
4.~/Sitesに適当にファイルを放り込む
scpでもなんでも。
またお好みでシンボリックリンクを張ってもよい
cd ~/Sites/ ln -s ~/Media/
5.とりあえず起動
sudo lighttpd -f /etc/lighttpd.conf
Safariでhttp://localhost/を見てみる
6.起動・停止をお手軽に
BossPrefsのプラグインにしてみる*1。
/Applications/BossPrefs.app/services/lighttpd
lighttpd -f /etc/lighttpd.conf killall lighttpd lighttpd
これはよい。