当前位置: 代码迷 >> python >> 运行Django应用的Lighttpd出现“孩子退出状态13”错误
  详细解决方案

运行Django应用的Lighttpd出现“孩子退出状态13”错误

热度:33   发布时间:2023-07-14 08:58:02.0

我正在尝试通过mod_fscgi通过lighttpd运行我的Django应用程序。 不幸的是,它一直抛出我无法确定的错误。

这是配置:

cat /etc/lighttpd/lighttpd.conf 
server.modules              = (
                               "mod_expire",
                               "mod_setenv",
                               "mod_redirect",
                               "mod_rewrite",
                               "mod_compress",
                               "mod_access",
                               "mod_auth",
                               "mod_secdownload",
                               "mod_accesslog",
                               "mod_fastcgi",
#                               "mod_geoip"
)

server.document-root        = "/var/www/default"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/www/logs/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80


index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

expire.url = ("/img/" => "access plus 10 days")

$HTTP["host"] =~ “mydomain\.com” {
    server.document-root = "/var/www/servers/mydomain.com/awesomesite"
    accesslog.filename = "/var/www/logs/mydomain.com/access.log"
    server.errorlog = "/var/www/logs/mydomain.com/error.log"
    fastcgi.server = (
        ".fcgi" => (
            "localhost" => (
                # Use host / port instead of socket for TCP fastcgi
                # "host" => "127.0.0.1",
                # "port" => 3033,
                "bin-path" => "/var/www/servers/mydomain.com/awesomesite/mydomain.fcgi",
                "socket" => "/tmp/mydomain.sock",
                "check-local" => "disable",
                "min-procs" => 2,
                "max-procs" => 4,
                )
           )
     )
}

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

错误:

/var/www/logs/mydomain.com# cat error.log 
2014-03-10 09:01:26: (log.c.166) server started 
2014-03-10 09:01:26: (mod_fastcgi.c.1103) the fastcgi-backend /var/www/servers/mydomain.com/awesomesite/mydomain.fcgi failed to start: 
2014-03-10 09:01:26: (mod_fastcgi.c.1107) child exited with status 13 /var/www/servers/mydomain.com/awesomesite/mydomain.fcgi 
2014-03-10 09:01:26: (mod_fastcgi.c.1110) 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. mydomain
2014-03-10 09:01:26: (mod_fastcgi.c.1397) [ERROR]: spawning fcgi failed. 
2014-03-10 09:01:26: (server.c.976) Configuration of plugins failed. Going down. 

FCGI文件:

cat /var/www/servers/mydomain.com/awesomesite/mydomain.fcgi 
#!/usr/bin/env python
import sys, os

sys.path.insert(0, "/var/www/servers/mydomain.com")

os.environ['DJANGO_SETTINGS_MODULE'] = "awesomesite.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

FastCGI试图执行bin-path指定的脚本。 通过发出以下命令,确保脚本/var/www/servers/mydomain.com/awesomesite/mydomain.fcgi设置了执行标志:

ls -l /var/www/servers/mydomain.com/awesomesite/mydomain.fcgi

并验证是否为运行webserver / fastCGI的用户和/或组设置了x标志。