lighttpd - iPhoneでWebサーバーを動かす for 2.0+

  • 2008-09-05 (Fri) 03:21
lighttpd

iPhone iPod touchでhttpdを動かしてみます
1.1.4時代は3種類ほどinstallerにありましたが2.0以降でパッケージになっているのはlighttpdだけのようです。*1

インストール

cydiaCydiaからインストール。

Cydia→Search"lighttpd"

lighttpd

08/09/05時点ではパッケージにconfやplistファイルが含まれていません。そこでiPod touchでlighttpd - Okiraku Programmingを参考にさせて頂きconfファイル、plistファイル、なんとかの1つ覚えでbossprefsプラグインを作ってみました。

/etc/lighttpd.conf

  • ドキュメントルートを/var/mobile/Sites/に
  • ディレクトリ表示をenableに
  • localhostのみアクセス許可。
  • mimetypeにmp4追加

※ipod touchでは最後のusernameとgroupnameをコメント(#)にしないと起動しなかった。

server.modules = ( 
        "mod_access",
        "mod_alias",
		"mod_dirlisting",
 )
server.dir-listing = "enable"
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",
    ".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"
)
server.port = 80
server.bind = "127.0.0.1"
server.username = "nobody"
server.groupname = "nobody"

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

1.1.4時の配布ファイルに含まれていたものをパスだけ変更。

<?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

一応アップしておきます

  1. lighttpd.zipをDL&解凍
  2. lighttpd.confを/etc/にアップ
  3. com.amcgregor.lighttpd.plistを/System/Library/LaunchDaemons/にアップ
  4. lighttpdを/Applications/BossPrefs.app/services/にアップ
  5. /var/mobileにSitesディレクトリを作成
  6. BossprefsでlighttpdをON

以上で起動するはずです

スポンサードリンク

  • Posted by: iPoday
  • カテゴリー: ネイティブアプリ / Network
  • トピックパス:

    Home » ネイティブアプリ / Network lighttpd - iPhoneでWebサーバーを動かす for 2.0+

  • Tag : / / /
  • This post was displayed 4075 views
  • あとで読む ブログパーツ

Comments:3

adoribu 2008-09-06 (Sat) 14:29

こんにちわ、いつも参考にさせていただいてます。
上記のとおり設定してみましたがhttp://127.0.0.1/へアクセスすると
403を吐かれてしまいます。
パーミッションの設定もしくはSitesの中に何か入れなければならないとか
注意する点はありますでしょうか?

3091
iPoday 2008-09-06 (Sat) 14:39

こんにちわ:-D

lighttpd.confの最後の2行をコメントアウトするか削除でどうでしょ?

3092
adoribu 2008-09-06 (Sat) 16:18

早速ご回答ありがとうございます
最後の2行削除にて解決しました。

3094
Comment Form
:wink::lol::cry::roll::grin1::arrow::mrgreen::):-(:!::?::oops::-o:-D8-|8-):??:x::-P:|:ase::[]=:[:chin::hahaha::!!::heart::**::!!!::*o*::star1.0::star0.5::star0.0::ahhh::??:
プレビュー
Trackback URL
TrackBack URL for this entry
http://www.ipoday.com/trackback/lighttpd.html
TrackBack 送信フォーム
もしあなたのブログがトラックバック送信に対応していない場合にはこちらのフォームからトラックバックを送信することができます。
Trackback:0

このエントリにトラックバックはありません

Referer

Page Top