Lighttpd运行Django应用程序时“孩子退出状态为13”错误

时间:2014-03-10 09:12:30

标签: python django fastcgi lighttpd

我正在尝试使用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")

1 个答案:

答案 0 :(得分:1)

FastCGI正在尝试执行bin-path中指定的脚本。通过发出以下命令确保脚本/var/www/servers/mydomain.com/awesomesite/mydomain.fcgi具有执行标志:

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

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