FastCGI .fcgi Internal server error Django documentation incomplete

mistwang

LiteSpeed Staff
#2
You cannot expect real fcgi to work with lswsgi, they speak in different protocol, if it is pure wsgi application, it will work if you rename the file from wsgi to fcgi.

Have you tried the sample hello world wsgi code? rename it to fcgi?
 
#5
.wsgi shows Hello world properly no server error.

I have this added into .htaccess file
Code:
AddType application/x-httpd-wsgi .fcgi
# Rewrite all requests to index.fcgi for Django
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]

But .fcgi file shows 500 error

Here is the fcgi script

Code:
#!/usr/bin/python
import sys, os

# Show errors on stderr
sys.stdout = sys.stderr

# Custom python path
sys.path.insert(0, "/home/user")
sys.path.insert(1, "/home/user/django")

# Change directory to project location
os.chdir("/home/user/django")

# Set DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "domt.settings"

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

mistwang

LiteSpeed Staff
#6
Your application is talking FCGI protocol, it wont work with lswsgi, which talks in LSAPI protocol.
You have to update the code to use WSGI interface.
 
#7
This is still producing an internal server error.

Code:
import sys, os
sys.stdout = sys.stderr
sys.path.insert(0, "/home/user")
sys.path.insert(1, "/home/user/django")
os.chdir("/home/user/django")
os.environ['DJANGO_SETTINGS_MODULE'] = "django.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
 
#8
Error log shows

2014-11-04 18:30:34.887 [INFO] [11.22.333.44:62131-0#APVH_domain.com] connection to [/tmp/lshttpd/lswsgi.sock] on request #0, confirmed, 1, associated process: 855004, running: 0, error: Connection reset by peer!
2014-11-04 18:30:34.887 [NOTICE] [11.22.333.44:62131-0#APVH_domain.com] Max retries has been reached, 503!
2014-11-04 18:30:34.887 [NOTICE] [11.22.333.44:62131-0#APVH_domain.com] oops! 503 Service Unavailable
2014-11-04 18:30:34.887 [NOTICE] [11.22.333.44:62131-0#APVH_domain.com] Content len: 0, Request line: 'GET /~user/index2.fcgi HTTP/1.1'
2014-11-04 18:30:34.887 [INFO] [11.22.333.44:62131-0#APVH_domain.com] Cookie len: 292
2014-11-04 18:30:34.887 [NOTICE] [11.22.333.44:62131-0#APVH_domain.com] Redirect: #1, URL: /index2.fcgi
2014-11-04 18:30:34.887 [INFO] [11.22.333.44:62131-0#APVH_domain.com] abort request..., code: 4
2014-11-04 18:30:34.888 [INFO] [11.22.333.44:62131-0#APVH_domain.com] File not found [/home/user/public_html/503.shtml]
 

mistwang

LiteSpeed Staff
#9
/usr/local/apache/logs/stderr.log shows error related to django

2014-11-05 09:39:25.654 [STDERR] from django.core.wsgi import get_wsgi_application
ImportError2014-11-05 09:39:25.655 [STDERR] : No module named django.core.wsgi
it also have error for fastcgi
ImportError: 2014-11-05 07:24:04.235 [STDERR] from django.core.servers.fastcgi import runfastcgi
The django setup is wrong.
 
#10
/usr/local/apache/logs/stderr.log shows error related to django



it also have error for fastcgi


The django setup is wrong.

I have reinstalled django and all the required models, still showing an error

python index.fcgi
Traceback (most recent call last):
File "index.fcgi", line 18, in <module>
runfastcgi(method="threaded", daemonize="false")
File "/usr/lib64/python2.6/site-packages/django/core/servers/fastcgi.py", line 145, in runfastcgi
from django.core.servers.basehttp import get_internal_wsgi_application
File "/usr/lib64/python2.6/site-packages/django/core/servers/basehttp.py", line 20, in <module>
from django.core.management.color import color_style
File "/usr/lib64/python2.6/site-packages/django/core/management/__init__.py", line 68
commands = {name: 'django.core' for name in find_commands(__path__[0])}
^
SyntaxError: invalid syntax
 

Michael

Well-Known Member
Staff member
#11
Hello,

Have you tested this setup with Apache (and mod_wsgi)? It sounds like it is not an issue with LSWS, but rather an issue with the Django setup.

Cheers,

Michael
 
#12
The setup is working fine on the Apache server. Moving over to the Litespeed server, and this is our experience and thats why I'm posting to see how to make it compatible with Litespeed but new problems keep popping up one after another.
 

Michael

Well-Known Member
Staff member
#13
Just to clarify: This is working on this server when you switch to Apache (on this server) or it is working on another server that is running Apache?

Michael
 

Michael

Well-Known Member
Staff member
#14
Also, if the python command above is not working, then something is wrong with your Python backend setup. Running it from the command line has nothing to do with the web server.

Michael
 
#15
Also, if the python command above is not working, then something is wrong with your Python backend setup. Running it from the command line has nothing to do with the web server.

Michael
Hi Michael,

When I run python index.fcgi it shows the full website html with debug enabled for the script in command line, internal server error on the web server.
 

mistwang

LiteSpeed Staff
#16
This is still producing an internal server error.

Code:
import sys, os
sys.stdout = sys.stderr
sys.path.insert(0, "/home/user")
sys.path.insert(1, "/home/user/django")
os.chdir("/home/user/django")
os.environ['DJANGO_SETTINGS_MODULE'] = "django.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
just try that again if running from command line does not give any error about django.core .
 
Top