Saturday, October 11, 2008

iPod touch で lighttpd を動かす

基本的に以下のサイト通りにインストールやら設定をすれば動くようになる。




やったことは以下の通り。


  1. Jailbreak した iPod touch を用意

  2. Cydia を使って lighttpd をインストール

  3. /etc/lighttpd.conf を作成 (上記のサイトを参考にする)

  4. /var/mobile/Sites/ に index.html を作成

  5. パーミッションの設定を上手く設定する

  6. plist ファイルを作成する (上記のサイトを参考にする)
    /System/Library/LaunchDaemons/com.amcgregor.lighttpd.plist

  7. BossPrefs 用のファイルを作成する (上記のサイトを参考にする)
    /Applications/BossPrefs.app/services/lighttpd




参考にしたサイトの設定と、iPod touch に入っていた別のアプリケーションの設定が微妙に違っていたので、iPod touch に元々入っていた別のアプリケーションの設定をコピーして、それを lighttpd 用に書き換えて lighttpd の設定ファイルとすることにした。

設定したファイルの内容は以下の通り。

/etc/lighttpd.conf

server.modules = (
"mod_access",
"mod_alias",
)
server.document-root = "/var/mobile/Sites/"
index-file.names = (
"index.html", "index.htm",
)
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"
)
server.port = 80
server.bind = "127.0.0.1"
#server.username = "nobody"
#server.groupname = "nobody"



/System/Library/LaunchDaemons/com.amcgregor.lighttpd.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.amcgregor.lighttpd</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/lighttpd</string>
<string>-f</string>
<string>/etc/lighttpd.conf</string>
<string>-D</string>
</array>
<key>StandardErrorPath</key>
<string>/dev/null</string>
</dict>
</plist>



/Applications/BossPrefs.app/services/lighttpd

/bin/launchctl load -w /System/Library/LaunchDaemons/com.amcgregor.lighttpd.plist
/bin/launchctl unload -w /System/Library/LaunchDaemons/com.amcgregor.lighttpd.plist
com.amcgregor.lighttpd.plist
/Applications/BossPrefs.app/ssh.png




【参考】
iPod touchでlighttpd - Okiraku Programming
lighttpd - iPhoneでWebサーバーを動かす for 2.0+ - iPoday

No comments:

Post a Comment