Installing a django site on GoDaddy

Question:

I have never deployed a Django site before. I am currently looking to set it up in my deluxe GoDaddy account. Does anyone have any documentation on how to go about installing python and django on GoDaddy?

Asked By: Carl W.

||

Answers:

According to Godaddy, they can be able to use Python 2.7.2, and you may program if you have a deluxe edition of their web hosting. The way I understand it, python will work the moment you type the directory location of your python installation on the first row:

 #!/usr/local/bin/python2.7

But, when I tried to test it, it does not work. I enabled SSH on my account. I tried to connect with Putty, and it works if I run it. But, the problem is, the site just does not show up.

I tried to check what the version of Python is. I found out it is Python 2.4.3. So, I tried to locate their directory. I found that it may be:

 #!/usr/local/bin/python2.4

Or

 #!/usr/local/bin/python2.4/site.py - (not sure)

I tried every directory and changed every syntax possible. Nothing works.

Here is the article for supporting Python:
http://support.godaddy.com/help/article/7254/can-i-use-python-272-with-my-hosting-account?locale=en

So, either of the answers may be correct, according to my observation:

  • Godaddy claims they support Python. But don’t have the capacity to support it.
  • Godaddy supports Python. But, their tech supports don’t know how their servers works.
  • Godaddy claims they support Python. But, they really don’t.

But before jumping into conclusions, I have requested the change of my Godaddy Python Server to 2.7. I’ll update this post once I found out.

Update:
Godaddy claims that you may be able to run Python on Virtual Private Server or Dedicated Server, which I think is possible since you are running your own computer. Technically, you can install anything on your own computer. So, if Python runs, Django may run, but I doubt if they know how to support it.

Answered By: Franz Noel

I am not familiar with GoDaddy’s setup specifically, but in general, you cannot install Django on shared hosting unless it is supported specifically (a la Dreamhost). So unless GoDaddy specifically mentions Django (or possibly mod_wsgi or something) in their documentation, which is unlikely, you can assume it is not supported.

Theoretically you can install Python and run Django from anywhere you have shell access and sufficient permissions, but you won’t be able to actually serve your Django site as part of your shared hosting (i.e., on port 80 and responding to your selected hostname) because you don’t have access to the webserver configuration.

You will need either a VPS (GoDaddy offers them but it’s not their core business; Linode and Rackspace are other options), or a shared host that specifically supports Django (e.g. Dreamhost), or an application host (Heroku or Google App Engine). I recommend Heroku personally, especially if you are not confident in setting up and maintaining your own webserver.

Answered By: Andrew Gorcester

From other answers, it looks like GoDaddy shared hosting may not really support Django. Also, searching “django” in the search form returns nothing. If that is the case, I think your best bet would be using a reputable Django-friendly hosting companies listed here and here.

Answered By: pram

For future reference, as I assume you have moved on…

It 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.

  • Enable SSH access on your site.
  • Use 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.
  • SSH in, download VirtualEnv.py. You may get the entire tarball, but you only need the single file.
  • Run ‘/usr/bin/python2.7 virtualenv.py –system-site-packages your_new_env’
  • Run ‘source your_new_env/bin/activate’
  • Run ‘pip install django’
  • You can now follow the django tutorials directly, except of course not using runserver (as you already have a webserver running)

This 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.

EDIT

I 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:

  • Create your django project somewhere outside of the html directory structure. For example run django-admin in ~/code to create ~/code/yoursite
  • Follow the normal project and database setup as described in the Django tutorials.
  • From your virtual python environment, run ‘pip install flup’.
  • Create the following script ‘django_cgi.py’ inside ~/code (Note the python path!):

    #!~/your_new_env/bin/python
    import sys, os
    
    # Add a custom Python path for your project
    sys.path.insert(0, "/must/be/full/path/to/code/yoursite")
    
    # Set the DJANGO_SETTINGS_MODULE environment variable.
    # This should match the name for the project you added to the path above
    os.environ['DJANGO_SETTINGS_MODULE'] = 'yoursite.settings'
    
    from django.core.servers.fastcgi import runfastcgi
    runfastcgi(method="threaded", daemonize="false")
    
  • Inside ~/html, create or edit the .htaccess file with some variant of the following:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !=/mysite.cgi
    RewriteRule ^(.*)$ /mysite.cgi [QSA,L,PT]
    
  • Finally, create ~/html/mysite.cgi as follows:

    #!/bin/sh
    ~/your_new_env/bin/python ~/code/django_cgi.py 2>&1
    
  • Ensure everything is chmod’ed appropriately (755)

This is over simplified but functional, and should result in every request for any page or file being passed off to Django.

The 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.

References
Django with FastCGI
Start of Django Tutorials
VirtualEnv

Answered By: Chris

This is how I did it.

  1. Create on a real server (one you have full access to) a chroot with CENTOS 5.8
  2. Install all the needed packages there, including sqlite3-devel, a python 2.7 you compile yourself, virtual env etc.
  3. Install there the django and set it all up.
  4. Snapshot the entire chroot and copy it to the machine,
  5. For execution, just use the virtualenv and it works.

See the readme here : https://github.com/lawrencecreates/RHEL5-chroot/blob/master/README I also modified the code of that tool and it is what I used.

Answered By: h4ck3rm1k3
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.