As a little background, I've been developing a django application for a 1&1 shared hosting website. When I tried to port the app to the web, I followed the tutorial from here: http://robhogg.me.uk/post/2. The servers have Python 2.6, and I installed django and flup through SSH. Here is my .fsgi file...
#!/usr/bin/python
import sys, os
basepath = '/home/path/' # This isn't my actual homepath
sys.path.insert(0, basepath + '/.local/lib')
sys.path.insert(0, basepath + '/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method='threaded', daemonize='false')
...and here is my .htaccess file...
AddHandler fcgid-script .fcgi
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !(cgi-bin/mysite.fcgi)
RewriteRule ^(.*)$ cgi-bin/mysite.fcgi/$1 [QSA,L]
I also already gave the .fcgi script 755 permissions. When I run the .fcgi script, the homepage HTML prints on the console (which according to many sites means the script is good). But when I go to my website's domain, I was getting just an Index.html page that was sitting in my home directory. So I moved all the html files from the home directory, and tried again. But this time I get an error:
Forbidden
You don't have permission to access / on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I tried one more thing, and that was in the .htaccess file, changing
AddHandler fcgid-script .fcgi
to
AddHandler fastcgi-script .fcgi
After searching everywhere, I couldn't find a solution, so I followed the directions on this site: https://help.asmallorange.com/index.php?/Knowledgebase/Article/View/140 Even though it was a different host, it was the same concept with similar steps. I followed all the steps, creating a new project and everything, and in the end, had the same issue.
I've been through a ton of posts like this one, but none have had a solution that worked yet. Maybe this is a 1&1 specific issue, but I would really appreciate the help if anyone has any suggestions.
Inside the commands folder open up the runserver.py script with a text editor. Find the DEFAULT_PORT field. it is equal to 8000 by default. Change it to whatever you like DEFAULT_PORT = "8080"
str function in a django model returns a string that is exactly rendered as the display name of instances for that model. # Create your models here. This will display the objects as something always in the admin interface.
I got the same error as you got. But after I moved the .htaccess file to the django project folder, it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With