3

我对 Lighttpd、PHP 和 CGI​​ 有疑问。

我使用 OpenSUSE.10。

我已经构建了 lighttpd(版本 1.4.23)和 php(版本 5.3.0)。

这是 lighttpd 构建命令行:

./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

这是 php 构建命令行:

./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

这是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> 

这是 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"
}

这是启动 lig​​httpd 的命令行:

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

最后,lighttpd 创建了 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. 

我的问题是:

1) 有没有人在 Ubuntu 或 OpenSUSE 上启动 lig​​httpd + PHP + FastCGI 的成功经验?

2) 为什么生成 fcgi 失败了?

即我想使用这样的 index.php 来测试我的网络服务器:

<? php
phpinfo();
?>

PS:

如果我删除

$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"
}

从 lighttpd.conf 中,lighttpd 成功启动,Firefox 显示 index.html(但不是 index.php):

<html>

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

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

更新:

感谢您的回复。

lighttpd_error.log 准确地说 FCGI 和 PHP 解释器有问题。

是的,在 SUSE 或 Ubuntu 中可以使用反向移植,但它们也不起作用。

我认为这是操作系统的问题。

我有嵌入式设备:

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

交叉编译器为此设备构建应用程序:

mipsel-linux-gcc

因此,我为 MIPS 目标构建了 Lighttpd 和 php,将它们复制到此设备,然后...服务器开始正常工作。我可以从 Mozilla 看到 index.php!

我不知道为什么 Lighttpd+PHP 在 PC 上不起作用。

决定:我在这个问题上得分。

4

3 回答 3

1

如果我删除

$SERVER["socket"] == "127.0.0.1:443" { server.document-root = "/home/gosh/Desktop/web_server" ssl.engine = "enable" ssl.pemfile = "/home/gosh/桌面/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"

}

从 lighttpd.conf 中,lighttpd 成功启动,Firefox 显示 index.html

这可能是一个不同的问题,这里只涉及 SSL 和日志文件。这些日志文件是否存在?您的 SSL 密钥文件的信息在哪里?

我通常更喜欢使用预建包。是否没有可用于 SuSE 或 Ubuntu 的反向移植?

于 2009-09-07T09:06:44.580 回答
0

不确定,但大多数安装指南都说你应该在你的 php.ini 末尾添加这个

cgi.fix_pathinfo = 1
于 2009-08-30T16:34:13.090 回答
0

在 ubuntu 上,我注意到 php-cgi 二进制文件的路径设置不使用真正的二进制名称,ubuntu install php5-cgi 是因为默认配置试图指向 php-cgi,因此您会收到上述错误。这让我自己猜测了几分钟。

于 2010-01-10T17:41:40.770 回答