You are not logged in.

#1 2007-03-26 17:53:31

daltocli
Member
From: Kent, United Kingdom
Registered: 2007-03-20
Posts: 8
Website

Lighttpd + Php5

Hello, I have recently had a VPS installed with Arch Linux, loving it as a server OS so far.

I've come across an issue with LIGHTTPD with PHP5... I keep getting 500ISE errors. The infos I have at hand:

[root@moss ~]# /var/log/lighttpd/error.log

2007-03-25 22:30:23: (mod_fastcgi.c.1705) connect failed: Connection refused on unix:/tmp/php5-fastcgi.socket-3 
2007-03-25 22:30:23: (mod_fastcgi.c.2817) backend died, we disable it for a 5 seconds and send the request to another backend instead: reconnects: 0 load: 1 
2007-03-25 22:30:24: (mod_fastcgi.c.2396) unexpected end-of-file (perhaps the fastcgi process died): pid: 2543 socket: unix:/tmp/php5-fastcgi.socket-3 
2007-03-25 22:30:24: (mod_fastcgi.c.3181) response not received, request sent: 1133 on socket: unix:/tmp/php5-fastcgi.socket-3 for /xyz/info.php , closing connection

/etc/lighttpd/lighttpd.conf

##
# GeckHTTPd 1.4.13
# Configuration: Thomas David Dalladay-Morgan [daltocli]
# Created: 26th March, 2007.
##

## Modules to load.
server.modules = (
    "mod_rewrite",
    "mod_redirect",
    "mod_access",
    "mod_auth",
    "mod_status",
    "mod_fastcgi",
    "mod_proxy",
    "mod_cgi",
    "mod_compress",
    "mod_ssi",
    "mod_expire",
    "mod_accesslog"
)

## Main document root.
server.document-root           = "/home/abc/"

## Error log.
server.errorlog                = "/var/log/lighttpd/error.log"

## Index files.
index-file.names               = ( "index.html","index.htm","index.shtml","index.shtm","index.stm","index.php","index.cgi","index.pl","index.sh","index.py","index.rb" )

$HTTP["host"] == "localhost" {
    server.document-root = "/home/abc/html/"
    server.indexfiles = ( "index.html","index.htm","index.shtml","index.shtm","index.stm","index.php","index.cgi","index.pl","index.sh","index.py","index.rb" )
    fastcgi.server = (
        ".php" => (
            "localhost" => (
                "socket"   => "/tmp/php-fastcgi.socket",
                "bin-path" => "/usr/bin/php -c /etc/php.ini",
                "bin-environment" => (
                    "PHP_FCGI_CHILDREN"     => "32",
                    "PHP_FCGI_MAX_REQUESTS" => "5000"
                )
            )
        )
    )
}

## Include the MIME type conf file.
include "lighttpd-mimetypes.conf"

## Server software tag.
server.tag                     = "GeckHTTPd 1.4.13"

## AccessLog module.
accesslog.filename             = "/var/log/lighttpd/access.log"

## Access control.
url.access-deny                = ( "~",".inc",".lighttpd",".ht" )

$HTTP["url"] =~ "\.pdf$" {
    server.range-requests  = "disable"
}

## Static control excemption.
static-file.exclude-extensions = ( ".php",".cgi",".pl",".sh",".py",".rb" )

## PID file.
server.pid-file                = "/var/run/lighttpd.pid"

## Bind to port.
server.port                    = 80

## Bind to address.
server.bind                    = "67.159.42.170"

## Virtual directory listings.
dir-listing.activate           = "disable"

## Change to uid
server.username                = "nobody"

## Change to gid
server.groupname               = "nobody"

## Compress module.
compress.cache-dir             = "/home/abc/cache/"
compress.filetype              = ( "text/plain","text/html","application/xhtml+xml" )

## FastCGI module.
fastcgi.server = (
    ".php" => (
        "localhost" => (
            "socket"   => "/tmp/php5-fastcgi.socket",
            "bin-path" => "/usr/bin/php -c /etc/php.ini"
        )
    )
)

## CGI module.
cgi.assign = (
    ".cgi"                 => "/usr/bin/perl",
    ".pl"                  => "/usr/bin/perl",
    ".sh"                  => "/bin/sh",
    ".py"                  => "/usr/bin/python",
    ".rb"                  => "/usr/bin/ruby"
)

## Status module.
status.status-url              = "/xyz/geckhttpd-status"
status.config-url              = "/xyz/geckhttpd-config"

## Auth module.
auth.backend                   = "htdigest"
auth.backend.htdigest.userfile = "/home/abc/xyz/.htpasswd"

auth.require = (
    "/xyz" => (
        "method"  => "digest",
        "realm"   => "Server Administration",
        "require" => "valid-user"
    ),
    "/xyz/geckhttpd-status" => (
        "method"  => "digest",
        "realm"   => "Server Administration",
        "require" => "valid-user"
    ),
    "/xyz/geckhttpd-config" => (
        "method"  => "digest",
        "realm"   => "Server Administration",
        "require" => "valid-user"
    )
)

Any ideas?  I've removed some bits for security reasons.

Last edited by daltocli (2007-03-26 18:01:14)


Cheers,
~ Zahn Daltocli

Offline

#2 2007-03-26 18:14:40

blipblop
Member
Registered: 2007-03-07
Posts: 2

Re: Lighttpd + Php5

When php5 (as far as I tested php 5.2.1) is compiled with fast-cgi capabilities. When you start it as a normal binary without any cmdline args, even though you would set the PHP_FCGI_CHILDREN environment variable to some values it doesn't fork any children.
When you instead execute it with the -b option (listen to ip:port, like ./php -b 127.0.0.1:12345) it accepts that same environment variable and forks the correct number of worker children processes.
Just what I saw by strace. No idea if it helps you. I didn't study the php manuals closer.
Though.. I read on the net complaints that the php fcgi implementation is not very fcgi, more like imitating the apache sapi mod_php.

just my random ramblings
/Blipblop

Last edited by blipblop (2007-03-26 18:20:41)

Offline

#3 2007-03-26 22:35:22

daltocli
Member
From: Kent, United Kingdom
Registered: 2007-03-20
Posts: 8
Website

Re: Lighttpd + Php5

Hmm... I gave that a try, I still get the same problem!  Thanks for the suggestion though, I'm going to keep that bit in there big_smile

Last edited by daltocli (2007-03-26 22:35:58)


Cheers,
~ Zahn Daltocli

Offline

#4 2007-03-27 09:29:49

smoon
Member
Registered: 2005-08-22
Posts: 468
Website

Re: Lighttpd + Php5

You need to install php-cgi from extra since the php package does not provide cgi functionality on its own. In your lighttpd.conf you need to call `php-cgi' instead of `php':

...

$HTTP["host"] == "localhost" {
    server.document-root = "/home/abc/html/"
    server.indexfiles = ( "index.html","index.htm","index.shtml","index.shtm","index.stm","index.php","index.cgi","index.pl","index.sh","index.py","index.rb" )
    fastcgi.server = (
        ".php" => (
            "localhost" => (
                "socket"   => "/tmp/php-fastcgi.socket",
                "bin-path" => "/usr/bin/php-cgi -c /etc/php.ini",
                "bin-environment" => (
                    "PHP_FCGI_CHILDREN"     => "32",
                    "PHP_FCGI_MAX_REQUESTS" => "5000"
                )
            )
        )
    )
}

...

Also I think the "-c /etc/php.ini" commandline option is redundant since /etc/php.ini is the default for php to look at.

Offline

Board footer

Powered by FluxBB