Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to deploy a django project under a sub-URL on hostgator hosting. Here is the tutorial I was following: http://support.hostgator.com/articles/django-with-fastcgi

My index.fcgi looks like this:

#!/usr/bin/python2.7
import sys, os

sys.path.insert(0, "/home/my_project_dir")
sys.path.insert(0, "/home/my_project_dir/my_project/")
os.chdir("/home/my_project_dir/my_project/")
os.environ['DJANGO_SETTINGS_MODULE'] = "my_project.settings"

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

And the .htaccess looks like this:

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

Both of these files placed in a sub-direcotry /home/my_project_dir/public_html/dir/sub/ Problem is that when I try to access www.mydomain.com/dir/sub/ I get a 404 Resource not found error.

share|improve this question

1 Answer 1

grep for the 404 message in your access_log files, it will indicate whether the RewriteRule matched or not.

grep " 404 " access_log

either you will see

 127.0.0.1 - - [11/May/2012:23:50:56 +0100] "GET /index.fcgi/XXXX HTTP/1.1" 404 123

or

 127.0.0.1 - - [11/May/2012:23:50:56 +0100] "GET /XXXX HTTP/1.1" 404 123

the second ones indicates that the rewrite didn't match...

share|improve this answer
    
The rewrite does matches and I am getting this in error log: File does not exist: /home/my_project_dir/index.fcgi/the_url/ –  Irfan May 21 '12 at 10:27
    
make sure you can execute index.fcgi; chmod +x index.fcgi –  Tom H May 21 '12 at 10:31
    
it is executable, I can run it manually ./index.fcgi –  Irfan May 21 '12 at 10:36
    
what happens in the logs and response, if you call http://www.mydomain.com/index.fcgi ? –  Tom H May 21 '12 at 10:39
    
response prints the contents of fcgi file. I am not sure why it is not executing it –  Irfan May 21 '12 at 10:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.