Page 1 of 3 123 LastLast
Results 1 to 20 of 49

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Setting up lighttpd web server on 2.0

  1. #1
    Default 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:

    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
    #######################################################
    This is a simple configuration and you will want to review it. Change this line:

    Code:
    server.document-root     = "/private/var/mobile/Sites/"
    to reflect the location of your documents. You will also need to create the folder:

    Code:
    # mkdir /var/log/lighttpd
    and change the folders ownership to user nobody:

    Code:
    # chown nobody:nobody /var/log/lighttpd
    so that lighttpd can log events. Next I wanted it to run at startup so I created a plist:

    HTML 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>
    and saved it as /Library/LaunchDaemons/com.http.lighttpd.plist

    Then I loaded it with the command:

    Code:
    # launchctl load -w /Library/LaunchDaemons/com.http.lighttpd.plist
    and viewed my test html file with Safari. Success!!

    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

  2. The Following User Says Thank You to xogen For This Useful Post:

    kavehmb (10-13-2008)

  3. #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

  4. #3
    Quote Originally Posted by chunkd View Post
    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
    well if that is your doc root as specified in the config file, than to view it you would open safari and type one of the following:
    Code:
    http://127.0.0.1
    Code:
    http://localhost/
    if you see your page, success!

  5. #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)

  6. #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

  7. #6
    Talking 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
    #######################################################

  8. #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

  9. #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

  10. #9
    Last edited by madlogik; 08-11-2008 at 05:57 PM.

  11. #10
    What's Jailbreak?
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    4
    Thanked 2 Times in 1 Post
    To chmod /private/var/mobile to 755

    In terminal type:

    Code:
    chmod 755 /private/var/mobile

  12. #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?

  13. #12
    Quote Originally Posted by danc4498 View Post
    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?
    You are running this command as user mobile. It needs to be run as user root.

  14. #13
    Quote Originally Posted by xogen View Post
    You are running this command as user mobile. It needs to be run as user root.
    Well, I just tried this on the terminal, I logged in as root, and then ran the same command and got the same error.

  15. #14
    What firmware version are you using?

  16. #15
    Quote Originally Posted by xogen View Post
    What firmware version are you using?
    I'm using the jailbroken 2.0.1

  17. #16
    What's Jailbreak?
    Join Date
    Aug 2008
    Location
    Ukranine
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

  18. #17
    Quote Originally Posted by artysx View Post
    @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?
    thz, that's what i am talking about

  19. #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.

  20. #19
    Quote Originally Posted by danc4498 View Post
    I'm using the jailbroken 2.0.1
    I'm getting the same error message that danc is seeing. lighttpd runs fine by itself, but loading the plist fails with:
    launch_msg(): Socket is not connected
    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.

    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

  21. #20
    Quote Originally Posted by ajnakata View Post
    thz, that's what i am talking about
    The screen shot you showed displays a dynamic page (aka, a page generated with PHP/Perl or CGI). Only if PHP is available for 2.0, this would be easy with the files provider by someone a few post above.

Page 1 of 3 123 LastLast
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •