Django in Apache via mod_fcgid: How to track down FastCGI errors?

336 Views Asked by At

Due to a series of legacy infra-struture I have to deploy a Django application in an Apache server via mod_fcgid (no nginx, no mod_wsgi neither mod_uswgi).

I followed Django (1.8) instructions to deploy via FastCGI but mod_fcgid is exiting and I don't why.

The most useful piece of information I get is exit(communication error), terminated by calling exit(), return code: 120. No idea what might be raising that.


Here is Apache's error_log:

[Tue Feb 16 13:20:28 2016] [info] mod_fcgid: server subdomain.domain.com:/path/to/project/index.fcgi(15473) started
[Tue Feb 16 13:20:31 2016] [info] mod_fcgid: process /path/to/project/index.fcgi(15473) exit(communication error), terminated by calling exit(), return code: 120

This is my .htaccess:

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]

And this is my index.fcgi:

#!/path/to/project/venv/bin/python

import sys
import os

sys.path.insert(0, "/path/to/project")
os.chdir("/path/to/project")
os.environ['DJANGO_SETTINGS_MODULE'] = "project.settings"

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

I tried with and without the sys.path(…) and os.chdir(…) lines and some other minor changes such as using /path/to/project (where manage.py is) or /path/to/project/project (the package itself).

0

There are 0 best solutions below