lighttpd forum lighty > Trouble using lighttpd with php4 on Debian/Ubuntu

Posted by darehanl (Guest)
on 23.03.2006 15:21
I've tried my best, but no luck:(

I have a Ubuntu box that I wish have lighttpd running. I've installed 
packages:
lighttpd
php4-cgi
and probably a few others to resolve dependencies.

I've then called
$ lighty-enable-mod fastcgi

Okay, fastcgi is enabled. I check the path of php4-cgi and it's under 
/usr/bin/php4-cgi. However, lighttpd dies whenever I call a .php file. A 
non php file (static file) works fine, though. Error log says

2006-03-23 23:19:34: (response.c.452) Path         : /var/www/index.html
2006-03-23 23:19:34: (response.c.459) -- file found
2006-03-23 23:19:34: (response.c.460) Path         : /var/www/index.html
2006-03-23 23:19:34: (response.c.582) -- handling subrequest
2006-03-23 23:19:34: (response.c.583) Path         : /var/www/index.html
2006-03-23 23:19:34: (mod_staticfile.c.386) -- handling file as static 
file
2006-03-23 23:19:34: (response.c.594) -- subrequest finished

2006-03-23 23:20:18: (response.c.582) -- handling subrequest
2006-03-23 23:20:18: (response.c.583) Path         : /var/www/index.php
2006-03-23 23:20:18: (mod_fastcgi.c.3549) handling it in mod_fastcgi
2006-03-23 23:20:18: (mod_fastcgi.c.2691) write-req: error 0x080a3df0 0 
9000 0

I've tried looking at the configuration file, like so:
$ cat 10-fastcgi.conf
server.modules   += ( "mod_fastcgi" )

## Start an FastCGI server for php4 (needs the php4-cgi package)
fastcgi.server    = ( ".php" =>
                      ( "localhost" =>
                                        (
                          "bin-path" => "/usr/bin/php4-cgi",
                          "port" => 9000
                                        )
                                      )
                                )

Hm... I find no entry about "socket", so I try adding that.
"socket" => "/tmp/php4-fastcgi.socket"

This time, lighttpd doesn't even start. I never see the socket file 
/tmp/php4-fastcgi.socket get created, if this information is of any 
help.
Posted by darealh0ba (Guest)
on 15.04.2006 22:37
I have the exact same problem with Debain Sid.

Any news on that topic?
Posted by Thomas Bergheim
on 16.04.2006 18:53
darehanl wrote:
> I've tried looking at the configuration file, like so:
> $ cat 10-fastcgi.conf
> server.modules   += ( "mod_fastcgi" )
> 
> ## Start an FastCGI server for php4 (needs the php4-cgi package)
> fastcgi.server    = ( ".php" =>
>                       ( "localhost" =>
>                                         (
>                           "bin-path" => "/usr/bin/php4-cgi",
>                           "port" => 9000
>                                         )
>                                       )
>                                 )
> 
> Hm... I find no entry about "socket", so I try adding that.
> "socket" => "/tmp/php4-fastcgi.socket"
> 
> This time, lighttpd doesn't even start. I never see the socket file 
> /tmp/php4-fastcgi.socket get created, if this information is of any 
> help.

You can't use both UNIX-sockets and TCP/IP-sockets. If it's on 
localhost, UNIX-sockets are known to be faster.

Anyway, what happens if you run a script through php4-cgi through some 
other means, say the cli?
Posted by Jason Niberg (Guest)
on 16.04.2006 22:42
darealh0ba wrote:
> I have the exact same problem with Debain Sid.
> 
> Any news on that topic?

Well, seems that someone opened a Debian bug report about it:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=362827
Posted by Andreas Spanberg (Guest)
on 16.04.2006 22:50
Thomas Bergheim wrote:
> You can't use both UNIX-sockets and TCP/IP-sockets. If it's on 
> localhost, UNIX-sockets are known to be faster.

My config reads as follow:

server.modules   += ( "mod_fastcgi" )

## Start an FastCGI server for php4 (needs the php4-cgi package)
fastcgi.server    = ( ".php" =>
                      ((
                          "bin-path" => "/usr/bin/php-cgi",
                          "port" => 9000,
                          "max-procs" => 2,
                          "idle-timeout" => 20,
                          "bin-environment" => (
                            "PHP_FCGI_CHILDREN" => "4",
                             "PHP_FCGI_MAX_REQUESTS" => "5000"
                          ),
                         "bin-copy-environment" => (
                            "PATH", "SHELL", "USER"
                           ),

                                        )
                                      )
                                )

and here is a strace output of calling a simple php with only phpinfo() 
in it:

rt_sigaction(SIGPIPE, {SIG_IGN}, NULL, 8) = 0
rt_sigaction(SIGUSR1, {SIG_IGN}, NULL, 8) = 0
rt_sigaction(SIGINT, {0x804cfc0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGTERM, {0x804cfc0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGHUP, {0x804cfc0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGALRM, {0x804cfc0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGCHLD, {0x804cfc0, [], SA_SIGINFO}, NULL, 8) = 0
open("/dev/null", O_RDONLY|O_LARGEFILE) = 8
close(8)                                = 0
fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
fcntl64(4, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
time(NULL)                              = 1145220294
poll([{fd=4, events=POLLIN}], 1, 1000)  = 0
time(NULL)                              = 1145220295
poll([{fd=4, events=POLLIN}], 1, 1000)  = 0
time(NULL)                              = 1145220296
poll([{fd=4, events=POLLIN, revents=POLLIN}], 1, 1000) = 1
accept(4, {sa_family=AF_INET, sin_port=htons(1088), 
sin_addr=inet_addr("192.168.1.2")}, [16]) = 8
brk(0x80d2000)                          = 0x80d2000
brk(0x80f3000)                          = 0x80f3000
fcntl64(8, F_SETFD, FD_CLOEXEC)         = 0
fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
ioctl(8, FIONREAD, [0])                 = 0
read(8, 0x80db420, 4159)                = -1 EAGAIN (Resource 
temporarily unavailable)
accept(4, 0xbfaa3158, [112])            = -1 EAGAIN (Resource 
temporarily unavailable)
time(NULL)                              = 1145220296
poll([{fd=4, events=POLLIN}, {fd=8, events=POLLIN, revents=POLLIN}], 2, 
1000) = 1
ioctl(8, FIONREAD, [444])               = 0
read(8, "GET /test.php HTTP/1.1\r\nHost"..., 4159) = 444
stat64("/var/www/test.php", {st_mode=S_IFREG|0664, st_size=5841, ...}) = 
0
open("/var/www/test.php", O_RDONLY|O_LARGEFILE) = 9
close(9)                                = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=837, ...}) = 0
write(5, "2006-04-16 22:44:56: (mod_fastcg"..., 80) = 80
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++


any ideas?
Posted by darealh0ba (Guest)
on 19.04.2006 10:07
Jason Niberg wrote:
> darealh0ba wrote:
>> I have the exact same problem with Debain Sid.
>> 
>> Any news on that topic?
> 
> Well, seems that someone opened a Debian bug report about it:
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=362827

And also posted a solution, you might want to try it out.
Posted by Emil Sirbu (Guest)
on 29.04.2006 20:22
I have same problem on debian (testing/unstable) with lighttpd 1.4.11-4 
even bug  was closed with "We believe that the bug you reported is fixed 
in the latest version of lighttpd".

Thomas Bergheim wrote:

> Anyway, what happens if you run a script through php4-cgi through some 
> other means, say the cli?

When ai try to run  /usr/bin/php4-cgi -v I obtain the warning
PHP Warning:  mime_magic: type regex            BEGIN[[:space:]]*[{] 
application/x-awk invalid in Unknown on line 0

I found a solution for this warning on php.net and I added in 
/etc/php4/cgi/php.ini
[mime_magic]
mime_magic.magicfile = "/etc/apache2/magic"

After this... lighttpd + mod_fastcgi +php4-cgi work great.




Posted by Cristian R. Arroyo (Guest)
on 17.06.2006 23:40
Ok, I had the same problem, with PHP 4.4.2-CGI logging the following 
error when the fastcgi module of lighttpd 1.4.11-4 (as is shipped 
w/Dapper) was enabled, and I was trying to load any ".php" file:

(mod_fastcgi.c.2691) write-req: error 0x080a3d70 0 9000 0

The solution I found was to download the latest lighttpd package from 
Debian Unstable (lighttpd 1.4.11-6, get it from here: 
http://packages.debian.org/unstable/web/lighttpd) and replace my 
/etc/lighttpd/conf-available/10-fastcgi.conf file with the one in the 
Debian package.

Hope this is useful to other Ubuntu users.

Greetings from Argentina, home of Tango, Maradona & Dulce de Leche!
Posted by jig (Guest)
on 16.05.2007 11:09
Cristian R. Arroyo wrote:
> Ok, I had the same problem, with PHP 4.4.2-CGI logging the following 
> error when the fastcgi module of lighttpd 1.4.11-4 (as is shipped 
> w/Dapper) was enabled, and I was trying to load any ".php" file:
> 
> (mod_fastcgi.c.2691) write-req: error 0x080a3d70 0 9000 0
> 
> The solution I found was to download the latest lighttpd package from 
> Debian Unstable (lighttpd 1.4.11-6, get it from here: 
> http://packages.debian.org/unstable/web/lighttpd) and replace my 
> /etc/lighttpd/conf-available/10-fastcgi.conf file with the one in the 
> Debian package.
> 
> Hope this is useful to other Ubuntu users.

I just covered the same problem with the Ubuntu 6.06.1/Dapper Drake 
package.
No need to use another packet, just use the syntax from PHP tutorial 
from the wiki: http://trac.lighttpd.net/trac/wiki/TutorialLighttpdAndPHP

fastcgi.server = ( ".php" => ((
                     "bin-path" => "/path/to/php-cgi",
                     "socket" => "/tmp/php.socket"
                 )))