# Lighttpd and php-cli ends in segfaulting

## dronin

Hi there,

I have a problem with my lighttpd and php-cli (5.2.10-r1).

Every time I try to start lighty it crashes with following error output in the logfiles:

```
2009-09-18 19:34:57: (log.c.172) server started

2009-09-18 19:34:57: (mod_fastcgi.c.1087) the fastcgi-backend /usr/bin/php-cgi failed to start:

2009-09-18 19:34:57: (mod_fastcgi.c.1098) terminated by signal: 11

2009-09-18 19:34:57: (mod_fastcgi.c.1103) to be exact: it segfaulted, crashed, died, ... you get the idea.

2009-09-18 19:34:57: (mod_fastcgi.c.1105) If this is PHP, try removing the bytecode caches for now and try again.

2009-09-18 19:34:57: (mod_fastcgi.c.1398) [ERROR]: spawning fcgi failed.

2009-09-18 19:34:57: (server.c.928) Configuration of plugins failed. Going down.

```

and dmesg tells me:

```
grsec: From 212.123.98.153: exec of /usr/lib64/php5/bin/php-cgi (/usr/bin/php-cgi ) by /usr/sbin/lighttpd[lighttpd:29926] uid/euid:103/103 gid/egid:5005/5005, parent /usr/sbin/lighttpd[lighttpd:29923] uid/euid:103/103 gid/egid:5005/5005

grsec: From 212.123.98.153: exec of /sbin/killall5 (/bin/pidof -x /usr/sbin/lighttpd ) by /sbin/runscript.sh[runscript.sh:29927] uid/euid:0/0 gid/egid:0/0, parent /sbin/runscript.sh[runscript.sh:29924] uid/euid:0/0 gid/egid:0/0

grsec: From 212.123.98.153: exec of /usr/bin/rrdtool (/usr/bin/rrdtool - ) by /usr/sbin/lighttpd[lighttpd:29925] uid/euid:103/103 gid/egid:5005/5005, parent /usr/sbin/lighttpd[lighttpd:29923] uid/euid:103/103 gid/egid:5005/5005

grsec: From 212.123.98.153: exec of /bin/sleep (/bin/sleep 0.1 ) by /sbin/runscript.sh[runscript.sh:29928] uid/euid:0/0 gid/egid:0/0, parent /sbin/runscript.sh[runscript.sh:29915] uid/euid:0/0 gid/egid:0/0

php-cgi[29926]: segfault at 71 ip 00000000007200dc sp 00007667c61ff6b0 error 4 in php-cgi[400000+689000]

grsec: From 212.123.98.153: signal 11 sent to /usr/lib64/php5/bin/php-cgi[php-cgi:29926] uid/euid:103/103 gid/egid:5005/5005, parent /usr/sbin/lighttpd[lighttpd:29923] uid/euid:103/103 gid/egid:5005/5005 
```

attached my lighty config:

```
cat 04_fussel_vhost.conf

$HTTP["host"] =~ "^fussel.ch" {

        url.redirect = ( "^/(.*)" => "https://www.fussel.ch/$1" )

}

        url.rewrite-once = (

        "^/wiki/[sS]kins.*$"  =>      "$0",

        "^/wiki/([^\?]*)$"    =>      "/wiki/index.php?title=$1",

        )       

$HTTP["host"] == "www.fussel.ch" {

        var.localroot = var.vhostbase + "/fussel.ch"

        server.document-root = var.localroot + "/htdocs"

        var.localuid = "5007"

        var.localgid = "5007"

        var.localwrapper = "php-fussel"

        include "modules/mod_fastcgi.conf"

        accesslog.filename = var.localroot + "/var/log/access.log"

}

$SERVER["socket"] == "80.xxx.xxx.xxx:443" {

        var.localroot = var.vhostbase + "/fussel.ch"

        var.localuid = "5007"

        var.localgid = "5007"

        var.localwrapper = "php-fussel"

        include "modules/mod_fastcgi.conf"

        ssl.engine                  = "enable"

        ssl.pemfile                 = "/etc/lighttpd/ssl/fussel.ch/fussel.ch.pem"

        ssl.ca-file                 = "/etc/lighttpd/ssl/digital-bit.ch/startssl.ca.crt"

        server.name                 = "www.fussel.ch"

        server.document-root = var.localroot + "/htdocs" 
```

I don't know how to debug this deeper.

Apache with mpm-peruser and mod_php works fine, but I want to go back to lighty and not workaround here.

Hope somebody can help, thanks in advance

----------

## mimosinnet

I just had the same problem. In my case, the issue was with the configuration of extension_dir in /etc/php/cgi-php5.3/php.ini. Now I have:

```
# php-cgi -i | grep extension_dir

<tr><td class="e">extension_dir</td><td class="v">[b]/usr/lib64/php5.3/lib/extensions/no-debug-zts-20090626[/b]</td><td class="v">/usr/lib64/php5.3/lib/extensions/no-debug-zts-20090626</td></tr>
```

Cheers!

----------

