-
08-07-2008, 09:40 AM #1
Setting up lighttpd web server on 2.0
After I upgraded to 2.0 one of the things I missed the most was my web server. I used it to host my documentation, both in html form and pdf, and it kept it organized. When I saw that lighttpd was available for 2.0 I immediately installed it ...it didn't work oob, so here's what I did...
First I had to create a configuration file. I placed this here: /usr/etc/lighttpd.conf and it looks like this:
This is a simple configuration and you will want to review it. Change this line:Code:####################################################### ### lighttpd.conf BEGIN ####################################################### # #### modules to load server.modules = ( "mod_expire", "mod_auth", "mod_access", "mod_evasive", "mod_compress", "mod_status", "mod_redirect", "mod_accesslog" ) #### performance options (aggressive timeouts) server.max-keep-alive-requests = 6 server.max-keep-alive-idle = 15 server.max-read-idle = 15 server.max-write-idle = 15 ## single client connection bandwidth limit in kilobytes (0=unlimited) connection.kbytes-per-second = 0 ## global server bandwidth limit in kilobytes (0=unlimited) server.kbytes-per-second = 0 #### bind to interface (default: all interfaces) server.bind = "127.0.0.1" #### bind to port (default: 80) server.port = 80 #### run daemon as uid (default: don't care) server.username = "nobody" #### run daemon as gid (default: don't care) server.groupname = "nobody" #### set the pid file (newsyslog) server.pid-file = "/var/run/lighttpd.pid" #### name the server daemon publicly displays server.tag = "lighttpd" #### static document-root server.document-root = "/private/var/mobile/Sites/" #### chroot() to directory (default: no chroot() ) server.chroot = "/" #### files to check for if .../ is requested index-file.names = ( "index.html" ) #### disable auto index directory listings dir-listing.activate = "disable" #### disable ssl if not needed ssl.engine = "disable" #### compress module compress.cache-dir = "/private/var/tmp/" compress.filetype = ("text/plain", "text/html", "text/css", "image/png") #### expire module expire.url = ( "" => "access plus 6 hours") #### accesslog module accesslog.filename = "/var/log/lighttpd/access.log" #### error log server.errorlog = "/var/log/lighttpd/error.log" #### mod_evasive evasive.max-conns-per-ip = 250 #### limit request method "POST" size in kilobytes (KB) server.max-request-size = 1 #### disable multi range requests server.range-requests = "disable" #### disable symlinks server.follow-symlink = "disable" #### ONLY serve files with all lowercase file names server.force-lowercase-filenames = "disable" #### 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", ".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" ) # ####################################################### ### lighttpd.conf END #######################################################
to reflect the location of your documents. You will also need to create the folder:Code:server.document-root = "/private/var/mobile/Sites/"
and change the folders ownership to user nobody:Code:# mkdir /var/log/lighttpd
so that lighttpd can log events. Next I wanted it to run at startup so I created a plist:Code:# chown nobody:nobody /var/log/lighttpd
and saved it as /Library/LaunchDaemons/com.http.lighttpd.plistHTML Code:<?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.http.lighttpd</string> <key>ProgramArguments</key> <array> <string>/usr/sbin/lighttpd</string> <string>-f</string> <string>/usr/etc/lighttpd.conf</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
Then I loaded it with the command:
and viewed my test html file with Safari. Success!!Code:# launchctl load -w /Library/LaunchDaemons/com.http.lighttpd.plist
EDIT: server.groupname = "nobody"
should be: server.groupname = "nogroup"
but will work either way.Last edited by xogen; 08-11-2008 at 01:55 PM. Reason: Typo
-
The Following User Says Thank You to xogen For This Useful Post:
kavehmb (10-13-2008)
-
08-07-2008, 09:42 PM #2
Well I think I got it setup right just don't know how to veiw my test html file that I have put into /private/var/mobile/Sites
any help would be great thanks again
-
08-07-2008, 10:10 PM #3
-
08-08-2008, 06:09 PM #4
Hey, I just bought a 3g Iphone and jailbroke it. How can I install lighttpd straight away? is there a package somewhere I can download? (i dont have installer, only cydia)
-
08-10-2008, 01:25 AM #5
Hi exogen,
I wanted to run lighttpd too on my iPhone 2.0.1 2G.
I setup everything as explained by you above.
Now I have three problems/questions you might be able to help me with:
1. When I connect to the server I always get a "403 - Forbidden" response from it.
2. What's the suggested way to stop the daemon again?
3. Have you added lighttpd as a custom service to BossPrefs and did it work? If yes, how?
Thanks.
pac^man
-
08-10-2008, 09:15 PM #6
fixing the 403:
Well I modified the lighttpd.conf file.
- I removed the bind (so the server is now public and available to all computers on my lan)
- I removed the nobody user/group ... so everyone will have access
- I enabled the folder listing for files.
(In my setup, I have an index.html file wich looks cute as a front end.. an enter link that goes to /shared and I put all my files in there )
here is my lighttpd.conf file ..
for the rest THANKS A LOT FOR THE NICE TUT M8! !!!
(his setup is WAY more secure than mine... once again.. I DO want to share!)
Code:####################################################### ### lighttpd.conf BEGIN ####################################################### # #### modules to load server.modules = ( "mod_expire", "mod_auth", "mod_access", "mod_evasive", "mod_compress", "mod_status", "mod_redirect", "mod_accesslog" ) #### performance options (aggressive timeouts) server.max-keep-alive-requests = 6 server.max-keep-alive-idle = 15 server.max-read-idle = 15 server.max-write-idle = 15 ## single client connection bandwidth limit in kilobytes (0=unlimited) connection.kbytes-per-second = 0 ## global server bandwidth limit in kilobytes (0=unlimited) server.kbytes-per-second = 0 #### bind to interface (default: all interfaces) #server.bind = "127.0.0.1" #### bind to port (default: 80) server.port = 80 #### run daemon as uid (default: don't care) #server.username = "nobody" #### run daemon as gid (default: don't care) #server.groupname = "nobody" #### set the pid file (newsyslog) server.pid-file = "/var/run/lighttpd.pid" #### name the server daemon publicly displays server.tag = "lighttpd" #### static document-root server.document-root = "/private/var/mobile/Sites/" #### chroot() to directory (default: no chroot() ) server.chroot = "/" #### files to check for if .../ is requested index-file.names = ( "index.html" ) #### disable auto index directory listings dir-listing.activate = "enable" #### disable ssl if not needed ssl.engine = "disable" #### compress module compress.cache-dir = "/private/var/tmp/" compress.filetype = ("text/plain", "text/html", "text/css", "image/png") #### expire module expire.url = ( "" => "access plus 6 hours") #### accesslog module accesslog.filename = "/var/log/lighttpd/access.log" #### error log server.errorlog = "/var/log/lighttpd/error.log" #### mod_evasive evasive.max-conns-per-ip = 250 #### limit request method "POST" size in kilobytes (KB) server.max-request-size = 1 #### disable multi range requests server.range-requests = "disable" #### disable symlinks server.follow-symlink = "disable" #### ONLY serve files with all lowercase file names server.force-lowercase-filenames = "disable" #### 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", ".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" ) # ####################################################### ### lighttpd.conf END #######################################################
-
08-11-2008, 05:51 AM #7
can u share the "index.html" file?
actaully, lighttpd works well on my iphone 2.0, but how can i get the outlook like this?
Last edited by ajnakata; 08-11-2008 at 05:51 AM. Reason: Automerged Doublepost
-
08-11-2008, 02:09 PM #8
@madlogic "- I removed the nobody user/group ... so everyone will have access"
this is the user:group that the webserver switches to after starting.
if you are having access errors (403 - Forbidden) it's because the document root folder (/private/var/mobile/Sites) is not accessible by the webservers user (nobody). to fix this, chmod 755 /private/var/mobile so the user nobody can access the mobile user folder.
@ajnakata - if you want directory listing, change this line in your configuration and restart the web server: dir-listing.activate = "disable" to "enable"
@pac^man - you could use the command: launchctl unload /Library/LaunchDaemons/com.http.lighttpd.plist . I haven't tested it with bossprefs but the commands to load and unload should be the same in bossprefs. the 'ps' listing for lighttpd is lighttpd.Last edited by xogen; 08-11-2008 at 02:16 PM. Reason: Automerged Doublepost
-
08-11-2008, 05:54 PM #9
@: ajnakata
might not be as cute.. but can be modified
RapidShare: Easy Filehosting
ps: I put my files in a /shared subfolder
based on the work of :Brad Micallef
http://groups.google.com/group/iphon...8175fff9af8c5e
full template with all forms elements:
http://iphonewebdev.googlegroups.com/web/iPhone_template_ver1-1.zip?gda=p7_meEwAAAA4WuQBM7mTs1B5SjMMBCY2MR66MTMU 2sUveiUAkBXI8xTtkw2uIXHBpeenu2NQPK8HdBvCykUIZvI5Vc r9HQcP_Vpvmo5s1aABVJRO3P3wLQLast edited by madlogik; 08-11-2008 at 05:57 PM.
-
08-12-2008, 03:17 AM #10
To chmod /private/var/mobile to 755
In terminal type:
Code:chmod 755 /private/var/mobile
-
08-13-2008, 06:36 AM #11
Whenever I do the "launchctl load ...", I get the error: "launch_msg(): Socket is not connected" Anybody have an idea what to do from here?
-
08-13-2008, 09:23 AM #12
-
08-13-2008, 09:46 AM #13
-
08-13-2008, 12:52 PM #14
What firmware version are you using?
-
08-13-2008, 12:55 PM #15
-
08-13-2008, 04:29 PM #16
@xogen
I think @ajnakata was meaning about "outlook", is how to make it look iphone-like style, but not "ugly apache" as now
Is it possible or another web server is needed?
-
08-14-2008, 06:59 AM #17
-
08-14-2008, 10:21 AM #18
Any web server is going to list the same. To make it display "pretty", you have to make an html page and write some html.
-
08-14-2008, 06:34 PM #19
I'm getting the same error message that danc is seeing. lighttpd runs fine by itself, but loading the plist fails with:
I'm running on a 3G with 2.0.1. I found this error in some other forums regarding some other apps, but no useful information on what the error actually means.launch_msg(): Socket is not connected
Any ideas?
Edit: Forgot to mention, I did everything via ssh logged on as root.Last edited by eosjack; 08-14-2008 at 06:57 PM. Reason: additional info
-
08-15-2008, 02:26 AM #20



LinkBack URL
About LinkBacks
Reply With Quote
