I'm trying to set up a small django project on a bluehost shared server and am having trouble on what I think should be the last step - getting it running with fastcgi.
I installed python 3.7.0 and django 2.0.7 using miniconda and was able to create a project/app but i can't get it to display in a browser (FWIW, I have successfully done this with another bluehost site on a similar plan, though that site is under the "shared plus" plan while this one is just the basic, but I don't know if that's the issue)
In my ~/public_html/myproject/.htaccess file I have:
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /home/username/public_html/myproject/myproject.fcgi/$1 [QSA,L]
And in myproject.fcgi I have:
#!/home/username/miniconda3/bin/python
# -*- coding: utf-8 -*-
import sys, os
project_name = "myproject"
sys.stdout=open('/home/username/public_html/myproject/test.out','w')
print(project_name)
# Add a custom Python path.
sys.path.insert(0, "/home/username/miniconda3/bin/python")
sys.path.insert(0, "/home/username/public_html/myproject")
sys.path.insert(0, os.getcwd() + "/" + project_name)
os.environ['DJANGO_SETTINGS_MODULE'] = project_name + '.settings'
from django_fastcgi.servers.fastcgi import runfastcgi
from django.core.servers.basehttp import get_internal_wsgi_application
wsgi_application = get_internal_wsgi_application()
runfastcgi(wsgi_application, method="prefork", daemonize="false", minspare=1, maxspare=1, maxchildren=1)
This configuration worked for me on the other site, but here I am only able to run ./myproject.fcgi
successfully on the command line, but I get a 404 in the browser.
I'm unable to access my server logs so I added a line to the fcgi script to direct stdout to a file and find that the file is not produced, so I'm not sure if something's wrong with accessing my python install when I try to load the page in the browser, or what (I'm pretty new to this!)
I found practically my exact question here, unfortunately without an answer: Django with FastCGI gives 404 in browser but works on command line
Thanks!!