# Lighty, PHP and fcgi [SOLVED]

## fuzzykiller

I've used Lighty for some time now with PHP via FastCGI. However, it stopped working with a recent minor PHP update (I think).

Lighty doesn't start anymore, error.log says this:

```
2010-08-12 06:50:57: (log.c.166) server started

2010-08-12 06:50:57: (mod_fastcgi.c.1104) the fastcgi-backend /usr/bin/php-cgi failed to start:

2010-08-12 06:50:57: (mod_fastcgi.c.1108) child exited with status 0 /usr/bin/php-cgi

2010-08-12 06:50:57: (mod_fastcgi.c.1111) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version.

If this is PHP on Gentoo, add 'fastcgi' to the USE flags.

2010-08-12 06:50:57: (mod_fastcgi.c.1399) [ERROR]: spawning fcgi failed.

2010-08-12 06:50:57: (server.c.931) Configuration of plugins failed. Going down.

```

Funny, since the fastcgi USE flag was removed long ago.

On the command line, php-cgi is working just fine.

PHP and Lighty versions:

```
# php-cgi -v

PHP 5.2.14-pl0-gentoo (cgi) (built: Aug 12 2010 06:32:57)

Copyright (c) 1997-2010 The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

# lighttpd -v

lighttpd/1.4.26 (ssl) - a light and fast webserver

Build-Date: Jul 29 2010 23:59:47

```

FastCGI config:

```
fastcgi.server = ( ".php" =>

                            ( "localhost" =>

                                    (

                                            "socket"            =>              "/var/run/lighttpd/lighttpd-fastcgi-php-" + PID + ".socket",

                                            "bin-path"  =>              "/usr/bin/php-cgi",

                                                "max-procs" => 2,

                                                "bin-environment" => (

                                                        "PHP_FCGI_CHILDREN" => "8",

                                                        "PHP_FCGI_MAX_REQUESTS" => "500"

                                                ),

                                                "bin-copy-environment" => (

                                                        "PATH", "SHELL", "USER"

                                                ),

                                                "broken-scriptfilename" => "enable"

                                    )

                            )

                    )

```

emerge --info

```
 # emerge --info

Portage 2.1.8.3 (default/linux/amd64/10.0, gcc-4.4.3, glibc-2.11.2-r0, 2.6.35-gentoo x86_64)

=================================================================

System uname: Linux-2.6.35-gentoo-x86_64-Intel-R-_Core-TM-_i7_CPU_920_@_2.67GHz-with-gentoo-1.12.13

Timestamp of tree: Wed, 11 Aug 2010 14:15:02 +0000

app-shells/bash:     4.0_p37

dev-java/java-config: 2.1.11

dev-lang/python:     2.6.5-r3, 3.1.2-r4

dev-util/cmake:      2.8.1-r2

sys-apps/baselayout: 1.12.13

sys-apps/sandbox:    1.6-r2

sys-devel/autoconf:  2.65

sys-devel/automake:  1.11.1

sys-devel/binutils:  2.20.1-r1

sys-devel/gcc:       4.4.3-r2

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   2.2.6b

virtual/os-headers:  2.6.34

ACCEPT_KEYWORDS="amd64"

ACCEPT_LICENSE="* -@EULA dlj-1.1"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-O2 -pipe -march=core2"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/eselect/postgresql /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"

CXXFLAGS="-O2 -pipe -march=core2"

DISTDIR="/usr/portage/distfiles"

FEATURES="assume-digests distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"

GENTOO_MIRRORS="http://mirror.netcologne.de/gentoo http://ftp.uni-erlangen.de/pub/mirrors/gentoo"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j9"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.de.gentoo.org/gentoo-portage"

USE="X acl amd64 apache2 berkdb bzip2 cli cracklib crypt cxx fortran gdbm gpm iconv ipv6 mmx modules mudflap multilib ncurses nptl nptlonly openmp pam pcre perl pppd python readline reflection session spl sse sse2 ssl sysfs tcpd threads unicode xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias cgid" APACHE2_MPMS="worker" ELIBC="glibc" INPUT_DEVICES="mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="none null" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
```

PHP use flags (Apache is the main web server)

```
apache2 bcmath bzip2 cgi cli crypt ctype curl exif filter gd hash iconv imap ipv6 json mysql mysqli ncurses nls pcntl pcre pdo posix postgres readline reflection session simplexml soap sockets spl sqlite ssl threads tokenizer truetype unicode xml xmlreader xmlrpc xmlwriter xsl zip zlib (-adabas) -berkdb (-birdstep) -calendar -cdb -cjk -concurrentmodphp -curlwrappers -db2 -dbase (-dbmaker) -debug -doc -embed (-empress) (-empress-bcs) (-esoob) (-fdftk) (-firebird) -flatfile (-frontbase) -ftp -gd-external -gdbm -gmp -inifile -interbase -iodbc -kerberos -kolab -ldap -ldap-sasl -libedit -mcve -mhash -msql -mssql -oci8 -oci8-instant-client -odbc -pic -qdbm -recode -sapdb -sharedext -sharedmem -snmp (-solid) -spell -suhosin (-sybase-ct) -sysvipc -tidy -wddx -xpm -yaz
```

Additional PHP modules: fileinfo

Don't hesitate to ask for more info if I missed something. I just finished my first cup of coffee today.Last edited by fuzzykiller on Fri Aug 13, 2010 8:47 pm; edited 1 time in total

----------

## jodel

I had the same problem yesterday. Unfortunately I can't remember exactly how I fixed it, I tried so many things, recompiled lighty and php several times and almost god mad about it...

But it definitely had something to do with the USE flags so I post my flags. I think I changed the simplexml or xml USE flag a couple of times, did you change those recently?

my make.conf:

```

USE="gd cgi fastcgi mysql imap libwww maildir sasl ssl php mod_irc mod_muc web vhosts sieve simplexml"

```

my php useflags:

```

[ebuild   R   ] dev-lang/php-5.2.14  USE="berkdb bzip2 cgi cli crypt ctype filter gd gdbm hash iconv imap ipv6 json mysql ncurses nls pcre posix readline reflection session simplexml spl ssl tokenizer unicode xml xmlreader xmlwriter zlib -adabas -apache2 -bcmath -birdstep -calendar -cdb -cjk -concurrentmodphp -curl -curlwrappers -db2 -dbase -dbmaker -debug -discard-path -doc -embed -empress -empress-bcs -esoob -exif -fdftk -firebird -flatfile -force-cgi-redirect -frontbase -ftp -gd-external -gmp -inifile -interbase -iodbc -kerberos -kolab -ldap -ldap-sasl -libedit -mcve -mhash -msql -mssql -mysqli -oci8 -oci8-instant-client -odbc -pcntl -pdo -pic -postgres -qdbm -recode -sapdb -sharedext -sharedmem -snmp -soap -sockets -solid -spell -sqlite -suhosin -sybase-ct -sysvipc -threads -tidy -truetype -wddx -xmlrpc -xpm -xsl -yaz -zip" 0 kB

```

----------

## fuzzykiller

No, I didn't change these exact flags, but enabled the "soap" and "postgres" flags - I noticed that lighty wasn't running when I tried restarting apache and lighty after the flag change. Oh well. I'll try recompiling lighty later. At least I'm not alone.  :Very Happy: 

Fortunately it's totally uncritical since lighty doesn't really serve any dynamic content now.

----------

## fuzzykiller

The php-5.2"-current" ebuild in portage has been updated. It contains new USE flags and the php-cgi binary now displays "cgi-cfgi", like it should. Everything's back to normal.  :Smile: 

So recompiling did solve it. Kind of.  :Very Happy: 

Thanks, jodel.

----------

## CrazyCanuck

For those facing this and not seeing the answer (like me) fastcgi changed to fpm

 *Quote:*   

> fpm - builds & installs the PHP FastCgi Process Manager (only available in PHP-5.3 and newer)

 

----------

## Ant P.

php-fpm is completely separate from php-cgi (fastcgi), not replacing it.

----------

## fuzzykiller

 *CrazyCanuck wrote:*   

> For those facing this and not seeing the answer (like me) fastcgi changed to fpm

 The problem was an incorrect ebuild. The solution was the updated ebuild. That's what this thread was/is about.

----------

