Page 1 of 2 12 LastLast
Results 1 to 15 of 30

Thread: lighttp and php tutorial

  1. #1

    lighttp and php tutorial

    I will do this i quick steps.

    Install Lighttpd:

    ipkg install lighttpd

    Install Fast-CGI

    Code:
    ipkg install php-fcgi
    Then you edit /opt/etc/lighttpd/lighttpd.conf
    (I Use Joe editor so if you havnet install it do it by: "
    Code:
    ipkg install joe
    ")
    Code:
    joe /opt/etc/lighttpd/lighttpd.conf
    now start removing the # from
    Code:
    #                                "mod_fastcgi",

    Change
    server.document-root
    to something like:
    Code:
    server.document-root        = "/opt/share/www/"
    change the accesslog.filename
    to something like:
    #### accesslog module
    Code:
    accesslog.filename          = "/opt/share/www/log/access.log"
    Add ".sqlite" to:
    Code:
    url.access-deny             = ( "~", ".inc",".sqlite" )
    Now the most importent thing is to change the FastCGI setting to this:

    Code:
    fastcgi.server              = ( ".php" =>
                                      ((
                                        "host" => "192.168.1.1",
                                        "port" => 1026,
                                      ))
                                  )
    Hit
    Code:
    ctrl-k-x
    to save and exit

    Next thing is to create the file
    /opt/etc/init.d/S45php

    So you make the file by doing
    Code:
    joe /opt/etc/init.d/S45php
    and you put the following in it:

    Code:
    #!/bin/sh
    
    export PHP_FCGI_CHILDREN=1
    PORT=1026
    BIN=/opt/bin/php-fcgi
    #/opt/etc/php.d
    
    case $1 in
     start)
      $BIN -b $PORT &
      ;;
     stop)
      kill Pidof phpM  ;;
     *)
      echo "usage: $0 (start|stop)"
      exit 1
    esac
    Save and exit: "
    Code:
    Ctrl-k-x
    "

    Change the permission on it to make it executable:
    Code:
    chmod +x S45php
    Now you can start it by:
    Code:
    ./S45php start
    or it will start when you reboot the next time


    Thanks goes to Macsat for helping me to get it working on my unit
    -------------\______/-------------
    ASUS Wl-500W

  2. #2
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    15

    Unhappy Problems with fast-cgi

    Hi theboy50,

    thanks for this tutorial. I tried to get the lighttpd run with php support.
    I did what you've explained in your tutorial, but everytime when I start
    the lighttpd-server, the fast-cgi process was killed.

    Then I tried to start the fast-cgi directly with the lighttpd:

    Code:
    fastcgi.server = (".php" =>
                        ( "localhost" =>
                            (
                                "socket" => "/tmp/php-fastcgi.socket",
                                "bin-path" => "/opt/bin/php-fcgi",
                                "bin-environment" => (
                                "PHP_FCGI_CHILDREN" => "1",
                                "PHP_FCGI_MAX_REQUESTS" => "5000"
                                                     )
                            )
                        )
    )
    ps ax tells my that everything works fine:

    Code:
      168 admin       704 S   /opt/sbin/lighttpd -f /opt/etc/lighttpd/lighttpd.conf
      169 admin      1048 D   /opt/bin/php-fcgi
      170 admin      1048 D   /opt/bin/php-fcgi
      171 admin      1048 D   /opt/bin/php-fcgi
      172 admin      1048 D   /opt/bin/php-fcgi
    But after a few seconds ps ax tells me this:

    Code:
      168 admin       624 S   /opt/sbin/lighttpd -f /opt/etc/lighttpd/lighttpd.conf
      169 admin           Z   [php-fcgi]
      170 admin           Z   [php-fcgi]
      171 admin           Z   [php-fcgi]
      172 admin           Z   [php-fcgi]
    It seams that the motherprocess died and the child processes form php-fcgi are running as
    zombies.


    When I try to load a php file from the document-root I get the following error-message in the
    error-log-file form the lighttpd:

    Code:
    2006-05-14 11:08:36: (mod_fastcgi.c.1739) connect failed: Connection refused on 
    
    unix:/tmp/php-fastcgi.socket-3
    2006-05-14 11:08:36: (mod_fastcgi.c.2851) backend died, we disable it for a 5 seconds and send the request 
    
    to another backend instead: reconnects: 0 load: 1
    2006-05-14 11:08:36: (mod_fastcgi.c.2624) child signaled: 10
    2006-05-14 11:08:38: (mod_fastcgi.c.2430) unexpected end-of-file (perhaps the fastcgi process died): pid: 
    
    178 socket: unix:/tmp/php-fastcgi.socket-3
    2006-05-14 11:08:38: (mod_fastcgi.c.3172) child signaled: 10
    2006-05-14 11:08:38: (mod_fastcgi.c.3215) response not received, request sent: 862 on socket: 
    
    unix:/tmp/php-fastcgi.socket-3 for /index.php , closing connection
    Any Idea why the fast-cgi process get killed after a few seconds?

    I've installed the following packages, perhaps there is a package which makes trouble with fast-cgi:

    Code:
    Package: bash
    Version: 2.05b-5
    Depends: ncurses
    Status: install user installed
    Architecture: mipsel
    
    Package: bzip2
    Version: 1.0.3-5
    Status: install user installed
    Architecture: mipsel
    
    Package: coreutils
    Version: 5.2.1-9
    Conflicts: busybox-links
    Status: install user installed
    Architecture: mipsel
    
    Package: cron
    Version: 4.1-4
    Status: install user installed
    Architecture: mipsel
    
    Package: ctorrent
    Version: 1.3.4-2
    Depends: libstdc++, openssl
    Status: install user installed
    Architecture: mipsel
    
    Package: esmtp
    Version: 0.5.1-2
    Depends: libesmtp
    Conflicts: postfix
    Status: install user installed
    Architecture: mipsel
    
    Package: expat
    Version: 1.95.8-3
    Status: install ok installed
    Architecture: mipsel
    
    Package: fontconfig
    Version: 2.3.2-1
    Depends: expat, freetype, gconv-modules
    Status: install ok installed
    Architecture: mipsel
    
    Package: freetype
    Version: 2.1.10-1
    Depends: zlib
    Status: install ok installed
    Architecture: mipsel
    
    Package: gconv-modules
    Version: 2.2.5-5
    Status: install ok installed
    Architecture: mipsel
    
    Package: gdbm
    Version: 1.8.3-2
    Status: install ok installed
    Architecture: mipsel
    
    Package: ipkg
    Version: 0.99.149-2
    Status: install user installed
    Essential: yes
    Architecture: mipsel
    
    Package: less
    Version: 394-1
    Depends: ncurses
    Status: install user installed
    Architecture: mipsel
    
    Package: libbt
    Version: 1.05-4
    Depends: libcurl, openssl, zlib
    Status: install user installed
    Architecture: mipsel
    
    Package: libcurl
    Version: 7.15.3-1
    Status: install user installed
    Architecture: mipsel
    
    Package: libdb
    Version: 4.2.52-3
    Status: install user installed
    Architecture: mipsel
    
    Package: libesmtp
    Version: 1.0.4-1
    Status: install user installed
    Architecture: mipsel
    
    Package: libgd
    Version: 2.0.33-2
    Depends: libpng, libjpeg, freetype, fontconfig
    Status: install ok installed
    Architecture: mipsel
    
    Package: libjpeg
    Version: 6b-2
    Status: install ok installed
    Architecture: mipsel
    
    Package: libpng
    Version: 1.2.8-5
    Depends: zlib
    Status: install ok installed
    Architecture: mipsel
    
    Package: libstdc++
    Version: 0.1.12-3
    Depends: libuclibc++
    Status: install ok installed
    Architecture: mipsel
    
    Package: libuclibc++
    Version: 0.1.12-3
    Status: install ok installed
    Architecture: mipsel
    
    Package: libxml2
    Version: 2.6.23-1
    Depends: zlib
    Status: install user installed
    Architecture: mipsel
    
    Package: libxslt
    Version: 1.1.15-5
    Depends: libxml2
    Status: install user installed
    Architecture: mipsel
    
    Package: lighttpd
    Version: 1.4.11-2
    Depends: pcre, zlib
    Suggests: bzip2, libmemcache, lua, memcached, mysql, openldap, openssl
    Status: install user installed
    Architecture: mipsel
    
    Package: lzo
    Version: 1.08-2
    Status: install ok installed
    Architecture: mipsel
    
    Package: mc
    Version: 4.1.35-2
    Depends: ncurses
    Status: install user installed
    Architecture: mipsel
    
    Package: microperl
    Version: 5.8.6-3
    Status: install user installed
    Architecture: mipsel
    
    Package: ncurses
    Version: 5.5-1
    Status: install user installed
    Architecture: mipsel
    
    Package: openssl
    Version: 0.9.7d-4
    Status: install user installed
    Architecture: mipsel
    
    Package: pcre
    Version: 5.0-5
    Status: install ok installed
    Architecture: mipsel
    
    Package: php
    Version: 5.1.4-1
    Depends: bzip2, openssl, zlib, libxml2, libxslt, gdbm, libdb
    Status: install user installed
    Architecture: mipsel
    Conffiles:
    /opt/etc/php.ini 211ce782fa34ea1da50a564a63094fe3
    Installed-Time: 1147542320
    
    Package: php-fcgi
    Version: 5.1.4-1
    Depends: php (5.1.4), pcre
    Status: install user installed
    Architecture: mipsel
    
    Package: php-mysql
    Version: 5.0.3-13
    Depends: php, mysql
    Status: install user not-installed
    Architecture: mipsel
    
    Package: php-mysql
    Version: 5.0.3-12
    Depends: php, mysql
    Status: install user not-installed
    Architecture: mipsel
    
    Package: php-thttpd
    Version: 2.25b-5.0.3-5
    Depends: php
    Conflicts: thttpd
    Status: install user not-installed
    Architecture: mipsel
    
    Package: php-thttpd
    Version: 2.25b-5.1.4-1
    Depends: php (>= 5.0.3-8), libxml2
    Conflicts: thttpd
    Status: install user installed
    Architecture: mipsel
    
    Package: poptop
    Version: 1.2.1-1
    Status: install user installed
    Architecture: mipsel
    
    Package: readline
    Version: 5.0-2
    Status: install ok installed
    Architecture: mipsel
    
    Package: screen
    Version: 4.0.2-2
    Depends: termcap
    Status: install user installed
    Architecture: mipsel
    
    Package: termcap
    Version: 1.3.1-2
    Status: install ok installed
    Architecture: mipsel
    
    Package: torrent
    Version: 1.3-8
    Depends: libbt, coreutils
    Status: install user installed
    Architecture: mipsel
    
    Package: vsftpd
    Version: 2.0.1-7
    Status: install user installed
    Architecture: mipsel
    
    Package: xinetd
    Version: 2.3.13-4
    Status: install user installed
    Architecture: mipsel
    
    Package: zlib
    Version: 1.2.2-2
    Status: install user installed
    Architecture: mipsel
    Thankx.

    Best regards

    mmX

  3. #3

    No..

    I'm sorry. I don't know why that is.
    People are saying that php has ben updated and there are some proplems with it. Meaby thats the reason.
    -------------\______/-------------
    ASUS Wl-500W

  4. #4
    hmm i think i had the same problem a while ago.
    the solution was to change the socket path to a directory within the /opt directory.
    hope this helps you!
    Code:
    "socket" => "/opt/tmp/php-fastcgi.socket"

  5. #5
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    15
    I'd already tried to change the socket-path into the /opt area, but it doesn't help. After a few minutes the fcgi process becomes zombies.

    A also reinstalled all necessary packages.

    Any ideas?

    Thanks.

    mmX

  6. #6
    Ok i did everything as described in the tutorial but lighttpd won't start. What am I doing wrong?? I already tried changing the S80lighttpd config file to what is on the mascat page but this also did not help.

    What do I need to change ???

    Code:
    [NLBADB0Y@WL500g root]$ ps ax
      PID  Uid     VmSize Stat Command
        1 NLBADB0Y    416 S   /sbin/init
        2 NLBADB0Y        SW  [keventd]
        3 NLBADB0Y        RWN [ksoftirqd_CPU0]
        4 NLBADB0Y        SW  [kswapd]
        5 NLBADB0Y        SW  [bdflush]
        6 NLBADB0Y        SW  [kupdated]
        7 NLBADB0Y        SW  [mtdblockd]
       39 NLBADB0Y    276 S   telnetd
       44 NLBADB0Y    452 S   httpd eth1
       48 NLBADB0Y    312 S   syslogd -m 0 -O /tmp/syslog.log -S -l 7
       49 NLBADB0Y    288 S   klogd
       52 nobody      380 S   dnsmasq
       54 NLBADB0Y    248 S   nas /tmp/nas.lan.conf /tmp/nas.lan.pid lan
       57 NLBADB0Y        SW  [khubd]
       67 NLBADB0Y    184 S   lpd
       69 NLBADB0Y    188 S   p9100d -f /dev/usb/lp0 0
       71 NLBADB0Y    188 S   p9101d -f /dev/printers/0 1
       74 NLBADB0Y    240 S   waveservermain
       78 NLBADB0Y        SW  [usb-storage-0]
       79 NLBADB0Y        SW  [scsi_eh_0]
       84 NLBADB0Y    280 S   infosvr br0
       85 NLBADB0Y    428 S   watchdog
       89 NLBADB0Y    268 S   ntp
       95 NLBADB0Y        SW  [kjournald]
      102 NLBADB0Y   4116 S   /opt/bin/php-fcgi -b 1026
      120 NLBADB0Y    356 S   udhcpc -i eth1 -p /var/run/udhcpc0.pid -s /tmp/udhcpc
      126 NLBADB0Y   4208 S   /opt/bin/php-fcgi -b 1026
      132 NLBADB0Y    496 S   upnp -D -L br0 -W eth1
      134 NLBADB0Y    528 S   -sh
      137 NLBADB0Y    388 R   ps ax
    [NLBADB0Y@WL500g root]$
    Last edited by NLBADB0Y; 25-06-2006 at 15:49.

  7. #7

    lib-gd giving problems?

    I see that you have libgd installed. It kills my thttpd server (actually anything that works with libgd) So if you have your scripts accessing libgd that might be the problem (firmware 7e)

  8. #8

    cgi issue

    Hi, thanks for the great guide

    I have a problem though, since changing from thttpd to lighttpd, .cgi pages have stopped working. PHP support works excellent. When trying to access a cgi page, firefox asks if I want to save the file and ie goes 500-internal server error. I have no idea on how to fix this, please help.

  9. #9
    Join Date
    Apr 2005
    Location
    Vienna, Austria
    Posts
    191
    Quote Originally Posted by LinusW View Post
    Hi, thanks for the great guide

    I have a problem though, since changing from thttpd to lighttpd, .cgi pages have stopped working. PHP support works excellent. When trying to access a cgi page, firefox asks if I want to save the file and ie goes 500-internal server error. I have no idea on how to fix this, please help.
    Maybe the CGI script does not return valid http headers?

    Install "Live http headers" for firefix and see what it returns.

    I'm using lighttpd with cgi shell scripts without a problem.

  10. #10
    Was not able to check headers in firefox, since it only wants to d/l the file. However, in ie, the headers seem to be proper, but as far as i can see, the cgi-script doesn't work.

  11. #11
    I also had this issue after install lighttpd. In my case, change ".cgi" => "/bin/sh" in CGI module section in ligthttpd.conf solve the problem.

    #### CGI module
    cgi.assign = ( ".pl" => "/opt/bin/perl",
    ".cgi" => "/bin/sh" )

    Hope this help.

  12. #12
    Join Date
    Feb 2007
    Location
    CzechRep
    Posts
    151

    lighhtp sessions

    I have lighttp + php + MySQL working on Asus wl-500gP except PHP sessions.
    Directory
    Code:
    /opt/var/lib/php/session
    exists and contains some session files but I can't use session in web browser. What item should I check in php.ini and/or lighttpd.conf?
    I prefer
    Code:
    session.use_cookies =0
    but ...

    php.ini session part:
    Code:
    [Session]
    ; Handler used to store/retrieve data.
    session.save_handler = files
    
    ; Argument passed to save_handler.  In the case of files, this is the path
    ; where data files are stored. Note: Windows users have to change this 
    ; variable in order to use PHP's session functions.
    session.save_path = /opt/var/lib/php/session
    
    ; Whether to use cookies.
    session.use_cookies = 1
    
    ; This option enables administrators to make their users invulnerable to 
    ; attacks which involve passing session ids in URLs; defaults to 0.
    ; session.use_only_cookies = 1
    
    ; Name of the session (used as cookie name).
    session.name = PHPSESSID
    
    ; Initialize session on request startup.
    session.auto_start = 0
    
    ; Lifetime in seconds of cookie or, if 0, until browser is restarted.
    session.cookie_lifetime = 0
    
    ; The path for which the cookie is valid.
    session.cookie_path = /
    
    ; The domain for which the cookie is valid.
    session.cookie_domain =
    
    ; Handler used to serialize data.  php is the standard serializer of PHP.
    session.serialize_handler = php
    
    ; Define the probability that the 'garbage collection' process is started
    ; on every session initialization.
    ; The probability is calculated by using gc_probability/gc_divisor,
    ; e.g. 1/100 means there is a 1% chance that the GC process starts
    ; on each request.
    
    session.gc_probability = 1
    session.gc_divisor     = 1000
    
    ; After this number of seconds, stored data will be seen as 'garbage' and
    ; cleaned up by the garbage collection process.
    session.gc_maxlifetime = 1440
    
    ; PHP 4.2 and less have an undocumented feature/bug that allows you to
    ; to initialize a session variable in the global scope, albeit register_globals
    ; is disabled.  PHP 4.3 and later will warn you, if this feature is used.
    ; You can disable the feature and the warning separately. At this time,
    ; the warning is only displayed, if bug_compat_42 is enabled.
    
    session.bug_compat_42 = 1
    session.bug_compat_warn = 1
    
    ; Check HTTP Referer to invalidate externally stored URLs containing ids.
    ; HTTP_REFERER has to contain this substring for the session to be
    ; considered as valid.
    session.referer_check =
    
    ; How many bytes to read from the file.
    session.entropy_length = 0
    
    ; Specified here to create the session id.
    session.entropy_file =
    
    ;session.entropy_length = 16
    
    ;session.entropy_file = /dev/urandom
    
    ; Set to {nocache,private,public,} to determine HTTP caching aspects.
    ; or leave this empty to avoid sending anti-caching headers.
    session.cache_limiter = nocache
    
    ; Document expires after n minutes.
    session.cache_expire = 180
    
    ; trans sid support is disabled by default.
    ; Use of trans sid may risk your users security.
    ; Use this option with caution.
    ; - User may send URL contains active session ID
    ;   to other person via. email/irc/etc.
    ; - URL that contains active session ID may be stored
    ;   in publically accessible computer. 
    ; - User may access your site with the same session ID
    ;   always using URL stored in browser's history or bookmarks.
    session.use_trans_sid = 0
    
    ; The URL rewriter will look for URLs in a defined set of HTML tags.
    ; form/fieldset are special; if you include them here, the rewriter will
    ; add a hidden <input> field with the info which is otherwise appended
    ; to URLs.  If you want XHTML conformity, remove the form entry.
    ; Note that all valid entries require a "=", even if no value follows.
    url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

  13. #13
    Join Date
    Feb 2007
    Location
    CzechRep
    Posts
    151

    sessions

    I can see session variables stored in files (like sess_xxxxxxxxxxxx...) in
    Code:
    /opt/var/lib/php/session/
    - it seems to be ok, but when I want do use them (on other php page for instance) nothing happens; content of variables isn't displayed with echo command.


    There is everything ok on my local testing Xampp web server, so I hope php code is correct. I really don't know. Any idea? Maybe permissions? Please.

  14. #14
    Join Date
    Feb 2007
    Location
    CzechRep
    Posts
    151
    Nobody uses php sessions? !!Please help me set up lighttp to work with cookies - thats the problem!!!
    It works with SID in URL. with cookies not.Thanks
    Last edited by sarlacc; 30-06-2007 at 02:43.

  15. #15
    @sarlacc,


    did you ever solve this problem?
    right now i'm experiencing the same problem.
    I have a CMS running on the webserver with a mysql-db. however. when i want to log into the admin section of that cms. it refuses. because the session variable isn't filled with the admin flag.

    It seems to me that this problem is solved when the session variables work.

    i've tried chmod 777 /opt/var/lib/php/session but that didn't work.

    TIA

Page 1 of 2 12 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
  •