deploy django app on godaddy

Solutions on MaxInterview for deploy django app on godaddy by the best coders in the world

showing results for - "deploy django app on godaddy"
Anae
04 Oct 2020
1For future reference, as I assume you have moved on...
2
3It is possible to use Django on GoDaddy hosting, using VirtualEnv as they recommend. Python 2.7 is natively installed and works fine, though it isn't the default version to be run.
4
5Enable SSH access on your site.
6Use the hosting panel to setup your intial MySQL database. It doesn't need any entries, just make sure it exists and note down the connection info.
7SSH in, download VirtualEnv.py. You may get the entire tarball, but you only need the single file.
8Run '/usr/bin/python2.7 virtualenv.py --system-site-packages your_new_env'
9Run 'source your_new_env/bin/activate'
10Run 'pip install django'
11You can now follow the django tutorials directly, except of course not using runserver (as you already have a webserver running)
12This works for me on a deluxe account, though I would still recommend that anyone who definitely wants to use Django seek alternate hosting. GoDaddy is not very friendly, and I am not certain that everything will continue to work.
13
14
15EDIT
16
17I realized there may also be some confusion in how to get Django running normally inside Apache, without the regular mod_* options. This was my approach:
18
19Create your django project somewhere outside of the html directory structure. For example run django-admin in ~/code to create ~/code/yoursite
20Follow the normal project and database setup as described in the Django tutorials.
21From your virtual python environment, run 'pip install flup'.
22Create the following script 'django_cgi.py' inside ~/code (Note the python path!):
23
24#!~/your_new_env/bin/python
25import sys, os
26
27# Add a custom Python path for your project
28sys.path.insert(0, "/must/be/full/path/to/code/yoursite")
29
30# Set the DJANGO_SETTINGS_MODULE environment variable.
31# This should match the name for the project you added to the path above
32os.environ['DJANGO_SETTINGS_MODULE'] = 'yoursite.settings'
33
34from django.core.servers.fastcgi import runfastcgi
35runfastcgi(method="threaded", daemonize="false")
36Inside ~/html, create or edit the .htaccess file with some variant of the following:
37
38RewriteEngine On
39RewriteCond %{REQUEST_URI} !=/mysite.cgi
40RewriteRule ^(.*)$ /mysite.cgi [QSA,L,PT]
41Finally, create ~/html/mysite.cgi as follows:
42
43#!/bin/sh
44~/your_new_env/bin/python ~/code/django_cgi.py 2>&1
45Ensure everything is chmod'ed appropriately (755)
46This is over simplified but functional, and should result in every request for any page or file being passed off to Django.
47
48The reason for this runaround is that GoDaddy provides only native CGI support for old versions of Python we can't use, so we must use our virtual environment. While we cannot use that directly in the CGI scripts, we can fortunately run a shell script and invoke it manually. The mod_rewrite rule just ensures all traffic goes through Django.
49
50References
51Django with FastCGI
52Start of Django Tutorials
53VirtualEnv