If I browse to my site, I get a 500 "internal server error." However, if I SSH into my server and go to my site's folder and run "python mysite.fcgi" I see the HTML rendered fine. Obviously, something is wrong, but I'm not sure what.
Here is my .htaccess file:
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(static/.*)$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]
Here is my mysite.fcgi file:
#!/usr/bin/python2.5
import sys, os
sys.path.insert(0, "/kunden/homepages/34/[mydir]/htdocs/projects/django")
sys.path.insert(1, "/kunden/homepages/34/[mydir]/lib/python/site-packages")
os.chdir("/kunden/homepages/34/[mydir]/htdocs/projects/django/mysite")
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(["method=threaded", "daemonize=false"])
I'm setting this up on 1and1. It has been a pain, but I think I'm close.
With CGIs a 500 server error is often caused by bad header data being output by your CGI before the HTML code. You should output the content-type and TWO carriage returns "\n" before the html begins. Any unexpected output will cause the 500 error.
I'm not a Python guy so here's a Perl example. ;-)
You may be able to find the exact cause in your server logs. Always check there first when you see 500 errors.
Try:
And then chmod 777 that folder.
If you can run it as ssh, and apache is running as www-data (or some UID other than yours), it is possible that it is trying to write to the eggcache and getting a permission denied.