views:

1808

answers:

4

Hello.

I have a problem with Lighttpd, PHP and CGI.

I use OpenSUSE.10.

I have builded lighttpd (version 1.4.23) and php (version 5.3.0).

This is lighttpd build command lines:

./configure --prefix=/home/gosh/Desktop/web_server/lighttpd_native_installed --without-zlib --enable-ssl --enable-openssl --with-openssl=/home/gosh/Desktop/web_server/openssl_native_installed --with-openssl-includes=/home/gosh/Desktop/web_server/openssl_native_installed/include --with-openssl-libs=/home/gosh/Desktop/web_server/openssl_native_installed/lib --without-pcre --with-zlib --without-bzip2

make
make install

This is php build command lines:

./configure --prefix=/home/gosh/Desktop/web_server/php_native_installed --without-iconv --disable-libxml --disable-dom --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear --enable-fastcgi --enable-force-cgi-redirect

make
make install

This is php, php-cgi -v:

gosh@suse:~/Desktop/web_server> /home/gosh/Desktop/web_server/php_native_installed/bin/php -v
PHP 5.3.0 (cli) (built: Aug 30 2009 03:56:22) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
gosh@suse:~/Desktop/web_server> /home/gosh/Desktop/web_server/php_native_installed/bin/php-cgi -v
PHP 5.3.0 (cgi-fcgi) (built: Aug 30 2009 03:55:55)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
gosh@suse:~/Desktop/web_server>

This is lighttpd.conf:

server.document-root = "/home/gosh/Desktop/web_server"

server.port = 81

mimetype.assign = (
  ".html" => "text/html", 
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png" 
)

index-file.names = ( "index.php" )

server.modules = (
                   "mod_fastcgi",
                   "mod_accesslog"
                 )

accesslog.filename   = "/home/gosh/Desktop/web_server/lighttpd_access0.log"
server.accesslog     = "/home/gosh/Desktop/web_server/lighttpd_access000.log"

fastcgi.debug = 1
fastcgi.server = ( 
                    ".php" => 
                    (( 
                        "bin-path" => "/home/gosh/Desktop/web_server/php_native_installed/php-cgi -c /home/gosh/Desktop/web_server/php.ini",
                        "socket" => "php.socket" 
                    )),
                    ".html" => 
                    (( 
                        "bin-path" => "/home/gosh/Desktop/web_server/php_native_installed/php-cgi -c /home/gosh/Desktop/web_server/php.ini",
                        "socket" => "php.socket" 
                    ))
                 )

$SERVER["socket"] == "127.0.0.1:443" {
    server.document-root = "/home/gosh/Desktop/web_server"
    ssl.engine = "enable"
    ssl.pemfile = "/home/gosh/Desktop/web_server/lighttpd.pem"

    server.errorlog      = "/home/gosh/Desktop/web_server/lighttpd_error.log"
    server.accesslog     = "/home/gosh/Desktop/web_server/lighttpd_access1.log"
    accesslog.filename   = "/home/gosh/Desktop/web_server/lighttpd_access2.log"
}

This is command line to start lighttpd:

sudo /home/gosh/Desktop/web_server/lighttpd_native_installed/sbin/lighttpd -f /home/gosh/Desktop/web_server/lighttpd.conf -m /home/gosh/Desktop/web_server/lighttpd_native_installed/lib

And, finally, lighttpd creates lighttpd_error.log:

2009-08-30 04:44:01: (log.c.172) server started 
2009-08-30 04:44:01: (mod_fastcgi.c.1365) --- fastcgi spawning local 
    proc: /home/gosh/Desktop/web_server/php_native_installed/php-cgi -c /home/gosh/Desktop/web_server/php.ini 
    port: 0 
    socket php.socket 
    min-procs: 4 
    max-procs: 4 
2009-08-30 04:44:01: (mod_fastcgi.c.1390) --- fastcgi spawning 
    port: 0 
    socket php.socket 
    current: 0 / 4 
2009-08-30 04:44:01: (mod_fastcgi.c.1087) the fastcgi-backend /home/gosh/Desktop/web_server/php_native_installed/php-cgi -c /home/gosh/Desktop/web_server/php.ini failed to start: 
2009-08-30 04:44:01: (mod_fastcgi.c.1091) child exited with status 2 /home/gosh/Desktop/web_server/php_native_installed/php-cgi -c /home/gosh/Desktop/web_server/php.ini 
2009-08-30 04:44:01: (mod_fastcgi.c.1094) 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. 
2009-08-30 04:44:01: (mod_fastcgi.c.1398) [ERROR]: spawning fcgi failed. 
2009-08-30 04:44:01: (server.c.928) Configuration of plugins failed. Going down.

My questionis are:

1) has anybody successful experience in launching lighttpd + PHP + FastCGI on Ubuntu or OpenSUSE?

2) why spawning fcgi failed?

I.e. I want to use such index.php to test my web-server:

<? php
phpinfo();
?>

P.S.:

If I remove

$SERVER["socket"] == "127.0.0.1:443" {
    server.document-root = "/home/gosh/Desktop/web_server"
    ssl.engine = "enable"
    ssl.pemfile = "/home/gosh/Desktop/web_server/lighttpd.pem"

    server.errorlog      = "/home/gosh/Desktop/web_server/lighttpd_error.log"
    server.accesslog     = "/home/gosh/Desktop/web_server/lighttpd_access1.log"
    accesslog.filename   = "/home/gosh/Desktop/web_server/lighttpd_access2.log"
}

from lighttpd.conf, lighttpd successfully starts and Firefox displays index.html (but not index.php):

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Yabaaa!!!</title>
</head>

<body>
HELLO!!!
</body>
</html>

Gosh. Thx.

A: 

not sure, but most installation guides say that u should add this at the end of you php.ini

cgi.fix_pathinfo = 1
Thank u for reply.But the solution you offered did not solve the problem(I had already hopeless followed this advice...This was my php.ini:extension_dir = /home/gosh/Desktop/web_serverauthorization_state = falsecgi.fix_pathinfo = 1
Gosh
+1  A: 

If I remove

$SERVER["socket"] == "127.0.0.1:443" { server.document-root = "/home/gosh/Desktop/web_server" ssl.engine = "enable" ssl.pemfile = "/home/gosh/Desktop/web_server/lighttpd.pem"

server.errorlog      = "/home/gosh/Desktop/web_server/lighttpd_error.log"
server.accesslog     = "/home/gosh/Desktop/web_server/lighttpd_access1.log"
accesslog.filename   = "/home/gosh/Desktop/web_server/lighttpd_access2.log"

}

from lighttpd.conf, lighttpd successfully starts and Firefox displays index.html

This might be a different problem, here only concerning SSL and Logfiles. Do these Logfiles exist? Where's the information about your key-file for SSL?

I'd generally prefer the use of prebuilt-packages. Are there no backports available for SuSE or Ubuntu?

ppuschmann
A: 

Thx for responses.

lighttpd_error.log exactly says that there is a problem with FCGI and PHP interpreter.

Yes, backports are available ion SUSE or Ubuntu, but they do NOT work too.

I think it is the OS problem.

I have embedded device:

CPU: AMD AU1000 (MIPS platform, not x86)
RAM: 64 MB
HDD: 120 GB
LAN: ethernet controller

Cross compiler to buils apps for this device:

mipsel-linux-gcc

So, I have builded Lighttpd and php for MIPS target, copied them to this device and... server started to work normally. I could see index.php from Mozilla!

I do not know why Lighttpd+PHP does not work on PC.

DECISION: I score on the problem.

Gosh
A: 

On ubuntu i have notice that the path setup for the php-cgi binary does not use the real binary name, ubuntu install php5-cgi were as the default configuration trys to point to php-cgi hence you get the above error. It had me guessing for a few minutes myself.

Ryan