Code


Version 2 (modified by Joost Meijer <webmaster@…>, 8 years ago) (diff)

Initial Full Version

Setting up Django at Webreus.nl

Introduction

Before I explain how you can setup Django on webreus.nl I should add a bit of context.

At the moment I'm in the process of creating a Django powered website. I was looking for the cheapest hosting I could find, as I do not think I'm pull too much traffic. Webreus is dirtcheap (just 10EUR a year) for the smallest package. For that price you get a lot, only no shell access.

Before I tried, they didn't have mod_python working properly (they ran python2.2), and did not have mysqldb. The kind people of webreus were able to set up both (mod_python now on python2.4), and my django setup works.

I'll quickly summarize how I got things working.

Home setup

First of all, I have a full django enabled webserver setup at home: running on windows XP with Uniform Server. I wanted to be able to test every aspect of Django at home with apache/mysql and mod_python.

One thing in this setup is out of the ordinary: Django is installed in the www part of filesystem, not in the python site_package directory. This will come in handy when things will be moved to webreus. I have django enabled through a .htaccess file:

SetHandler python-program
AddHandler mod_python .py
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE <yoursite>.settings
PythonDebug On

My directory structure is as follows

www
 + django
 |  + django (which is the django source)
 |  + mysite (which is mysite's source)
 + site-media

Setting all this up has been done by following the various installation guides.

Webreus setup

When this was all working I signed up with webreus. Within 2 days I had a new domain and all the information I needed. They run Plesk and do not provide shell access. So setting up everything is a bit different than normally.

Through Plesk databases can be setup, this involves following the Plesk manual. No rocket science at all, just some click work. In the end this gives you phpMyAdmin to configure (in my case) a mysql database. Make sure the database setup is the same as the 'home setup' (otherwise you'll just have to change the settings.py).

Then I uploaded all my local files, through a ftp upload to the 'httpdocs' directory. Again no rocket science.

Now the main trick comes: without shell access there is no way to setup the database according to the 'models.py'. The way I've solved this is to replicate my home mysql database to webreus. Just exporting the database tables with contents through phpMyAdmin and uploading them again at webreus.

This was enough to get everything to work. I can now serve to http://www.mydomain.nl/django and see my frontpage from Django.

If you have any questions, just let me know: find my contact details in the history of this page.