Setting up Django on GoDaddy Deluxe Shared Hosting

4,740 views
Skip to first unread message

Donald H

unread,
Dec 28, 2007, 5:20:38 PM12/28/07
to Django users
Has anyone had success in setting up Django on GoDaddy's Deluxe shared
hosting plan? It supports Python CGI, but has no shell access. I read
a previous post from October 2006, where I read of another user who
did the same things I did (guided by the django documentation for
shared hosts), but now I'm stuck. I'm hoping someone has managed more
success than this since October 2006.

I created a "myaite.fcgi" script, but I was confused by some of the
items. For example, adding the custom Python path with
"sys.path.insert(0,"/home/user/python")" - what is that? If python is
already installed at "/usr/bin/python", what would this do?

And I don't even know if fastcgi is accessible for python. I come
from a .Net/Java background and everything apache- and cgi-based is
quite foreign to me.

And I know I could switch to a different host, but I already have
several other domains hosted at godaddy and would prefer not to have
to change hosts to use Django.

Thanks for any direction you guys can offer (even if it's to tell me
it's not possible).

Donald H.

Tim Chase

unread,
Dec 28, 2007, 5:35:05 PM12/28/07
to django...@googlegroups.com
> Has anyone had success in setting up Django on GoDaddy's Deluxe shared
> hosting plan? It supports Python CGI, but has no shell access.

CGI != FastCGI != WSGI

If all they offer is CGI, the general consensus is that you ought
look elsewhere as (1) it's not supported in Django and (2) if it
was supported in Django, performance would be abysmal in an
off-the-charts sort of way. A new python process is started for
each request, all the code is hauled into memory for one request,
and then disposed of. Not bad for small sites with low-volume
traffic. But it easily gets swamped. A better alternative is
to have the python interpreter stick around with your code in
memory once and then pass requests to the existing code. Enter
FastCGI, WSGI and mod_python to solve this problem, each in its
own way.

Python does do CGI, FastCGI and WSGI as well as the obvious
mod_python. :)

Django/Python does FastCGI and WSGI as well as mod_python.

> And I don't even know if fastcgi is accessible for python. I come
> from a .Net/Java background and everything apache- and cgi-based is
> quite foreign to me.

Hopefully the above description helps clarify the "fastcgi !=
cgi" confusion here.


I don't know what GoDaddy offers in the package you are using.
If it's CGI, your outta luck. However, if they do offer FastCGI
or WSGI, you're in luck (nothing you mentioned sounded like they
offered mod_python).

-tim


Donald H

unread,
Dec 28, 2007, 7:17:19 PM12/28/07
to Django users
Thanks for the quick and thorough response, Tim!

I'll find out if the FastCGI they advertise as being available for
Ruby on Rails could also be made accessible to Python by following the
Shared Hosting instructions at the bottom of http://www.djangoproject.com/documentation/fastcgi/.

Donald H

unread,
Dec 29, 2007, 12:09:08 AM12/29/07
to Django users
Here's what I asked GoDaddy Support:

"Is FastCGI accessible from python scripts if I add my own handler? I
ask
this in specific relation to setting up Django. Is this known not to
work?"


Here's their response:

"FastCGI is accessible from Python scripts for our Linux hosting
accounts. We do not allow, however, the addition of a custom FastCGI
handler in our shared hosting accounts."


Does this mean I am definitively out of luck?


Thanks again for your help.



On Dec 28, 6:17 pm, Donald H <donald.hug...@gmail.com> wrote:
> Thanks for the quick and thorough response, Tim!
>
> I'll find out if the FastCGI they advertise as being available for
> Ruby on Rails could also be made accessible to Python by following the
> Shared Hosting instructions at the bottom ofhttp://www.djangoproject.com/documentation/fastcgi/.

Radomir Wojcik

unread,
May 10, 2013, 2:04:16 PM5/10/13
to django...@googlegroups.com, donald...@gmail.com
I was looking for the answer to this today and I wrote a tutorial on how to do this based on all the stuff I found on the net:

With the economy class Linux hosting its a bit tricky. For starters you don't have root access to the site packages so you cannot install for example MySQL-Python.

1. Godaddy has virtualenv installed, so first, create a virtual environment venv: (I use $HOME/lib/ for all the installed stuff below)

cd ~/
mkdir lib
cd lib
virtualenv --no-site-packages venv

The python package folder is $HOME/lib/venv/lib/python2.7/site-packages

2. Install the latest Django through pip

pip install Django

3. Create a new project

django-admin.py startproject mysite

4. Change the database configuration in mysite/setting.py file. When setting the path for the database file, please use the absolute path:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', 
        'NAME': '/var/chroot/home/content/11/10420811/lib/venv/mysite/mydatabase.db',                      
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                    
        'PORT': '',                     
    }
}

While in here there are a few other things to consider changing:

  • ADMINS = can be updated with your info
  • TIME_ZONE = 'America/Toronto'
  • LANGUAGE_CODE = 'en-ca'
  • STATIC_ROOT = '/var/chroot/home/content/11/10420811/lib/venv/mysite/static/'
  • Uncommenting admin in INSTALLED_APPS : 'django.contrib.admin',

This will save you some setup later!

5. Set the Locale information in $HOME/.bash_profile file, otherwise you cannot set the superuser when you sync the database. You can edit the file with vim:

 export LANG=en_US.UTF-8
 export LC_ALL=en_US.UTF-8

6. Now run the script using the script command:

source ~/.bash_profile

7. If everything is setup properly, you should be able to sync the database:

python2.7 manage.py syncdb

You should see the admin tables get created and it will ask you to create a new user.

8. Now we setup the dispatch functionality so we can access the webpage without running server through Django using flup. So download and untar flup:

cd ~/lib/venv/lib/python2.7/site-packages
wget http://pypi.python.org/packages/source/f/flup/flup-1.0.2.tar.gz#md5=24dad7edc5ada31dddd49456ee8d5254
tar -xvzf flup-1.0.2.tar.gz
mv flup-1.0.2/flup/ .

9. In $HOME/html folder, create dispatch.py and add the following lines of code:

#!/usr/local/bin/python2.7
import sys, os
sys.path += ['/your/home/path/lib/venv/lib/python2.7/site-packages']
sys.path += ['/your/home/path/lib/mysite/']
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

from flup.server.fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
WSGIServer(WSGIHandler()).run()

Also do a chmod +x dispatch.py to make the python script executable!

10. In $HOME/html/.htaccess file, add the following codes:

AddHandler fcgid-script .fcgi
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

# everything else sent to django
RewriteRule ^(dispatch\.py/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.py/$1 [L]

Another good thing to note is that you can ReWrite URLS if you have current applications isntalled, ie.e dokuwiki.

#Add this above "everything else sent to django"
#Below other folders with static content and PHP , etc..
#hosted at yourdomain/dokuwiki
RewriteRule ^(dokuwiki/.*)$ - [L]

#You can also create your "django" project at a different location rather than your domain root by changing the 2nd RewriteRule , i.e.:

# everything else sent to django
RewriteRule ^(dispatch\.py/.*)$ - [L]
RewriteRule ^(djangoproj/.*)$ dispatch.py/$1 [L]
#Make sure to create the djangoproj folder inside your html dir, cd html; mkdir djangproj
#This becomes a bit annoying because your urlpatterns in url.py will now always have to include 'djangoproj' at the beginning.

11. Update your urls.py file to look like so:

from django.conf.urls import patterns, include, url
from django.conf import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    (r'^static/(.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
    url(r'^admin/', include(admin.site.urls)),
)

This will ensure you can access the admin application, as well as the static root where all your img js and css are. Also note to copy the admin img/js/css from /django/contrib/admin/static. Mine was in

~/lib/venv/lib/python2.7/site-packages/django/contrib/admin/

I used cp -r to copy it over to my application static dir/var/chroot/home/content/11/10420811/lib/venv/mysite/static/

cp -r ~/lib/venv/lib/python2.7/site-packages/django/contrib/admin/ ~/lib/venv/mysite/static/

12. That is it, you should have access to your site now! Access to http://your.website.com/adminshould work!

Gerald Klein

unread,
May 10, 2013, 6:08:17 PM5/10/13
to django...@googlegroups.com, donald...@gmail.com
Wow thanks amazing work, I wondered if someone had figured out a way to do it. 

thanks 

--jerry


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

Gerald Klein DBA

Cont...@geraldklein.com

www.geraldklein.com

geraldklein.wordpress.com

j...@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580 


Tom Evans

unread,
May 13, 2013, 10:19:47 AM5/13/13
to django...@googlegroups.com
On Fri, May 10, 2013 at 7:04 PM, Radomir Wojcik <radz...@gmail.com> wrote:
> I was looking for the answer to this today and I wrote a tutorial on how to
> do this based on all the stuff I found on the net:
>
> With the economy class Linux hosting its a bit tricky. For starters you
> don't have root access to the site packages so you cannot install for
> example MySQL-Python.
>
> 1. Godaddy has virtualenv installed, so first, create a virtual environment
> venv: (I use $HOME/lib/ for all the installed stuff below)
>
> cd ~/
> mkdir lib
> cd lib
> virtualenv --no-site-packages venv
>
> The python package folder is $HOME/lib/venv/lib/python2.7/site-packages
>
> 2. Install the latest Django through pip
>
> pip install Django
>

Are you not missing a step between 1) and 2), you need to activate the
virtualenv, so that django (and all other libraries) are installed in
the right place.

Cheers

Tom

Kapil Chandra

unread,
Dec 8, 2013, 5:06:29 PM12/8/13
to django...@googlegroups.com
Just wanted to say that this seemed to work for getting Flask running on godaddy too (skipping the django specific steps of course) with two differences. In dispatch.py instead of:

from django.core.handlers.wsgi import WSGIHandler
WSGIServer(WSGIHandler()).run()
use:

from yourapp import app
WSGIServer(app).run()
And in .htaccess I had to add:

AddHandler fcgid-script .py

All the other steps were the same - thanks so much for posting this. 

saurabhm...@gmail.com

unread,
Mar 19, 2017, 10:22:17 AM3/19/17
to Django users, donald...@gmail.com
someone help me i am getting thi 500 internal error i dont understand whats wrong 

chandrashekhar Damahe

unread,
Jan 26, 2019, 9:43:57 AM1/26/19
to Django users
hii, i am follow these steps but i got error " The requested URL /dispatch.py/ was not found on this server. " will you help me to solve these error
Reply all
Reply to author
Forward
0 new messages