Porting a Django project to 1 and 1 web server with shared hosting

As a small background, I am developing a django application for the 1st and 1st web hosting. When I tried to transfer the application to the Internet, I went through the following tutorial: http://robhogg.me.uk/post/2 . There is Python 2.6 on the servers, 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 have also granted permissions to the .fcgi script 755. When I run the .fcgi script, the HTML page of the home page prints to the console (which, according to many sites, means the script is good). But when I go to my site, I only get the Index.html page, which is 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 message:

 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 could not find a solution, so I followed the directions on this site: https://help.asmallorange.com/index.php?/Knowledgebase/Article/View/140 Although it was a different host, it was the same concept with similar steps. I completed all the steps, creating a new project and that’s all, and, in the end, I had the same problem.

I went through a ton of posts like this one, but no one had a solution that still worked. This may be 1 and 1 specific problem, but I would really appreciate help if anyone has any suggestions.

+6
source share
1 answer

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

+1
source

Source: https://habr.com/ru/post/950761/


All Articles