Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Porting Django Project to 1&1 Shared Hosting Web-server

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.

like image 900
user2639703 Avatar asked Jul 31 '13 21:07

user2639703


People also ask

How do I run a Django project on a different port?

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"

What is the purpose of __ Str__ method in Django?

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.


1 Answers

I got the same error as you got. But after I moved the .htaccess file to the django project folder, it works.

like image 125
Wilson Avatar answered Sep 18 '22 16:09

Wilson