How it works
On all djangohosting.ch servers, there is a central lighttpd server which proxies requests directed to any of your domains to your private lighttpd server. You have full control over the configuration of your private lighttpd, as its config file is in your home directory.
To ensure that your logfiles and your applications get the right IP address (not the proxy's one), a module (mod_extforward) is enabled in your lighttpd configuration file which rewrites the headers appropriately. Also, iptables firewalling is enabled on the server, so no unauthorized user can connect locally to your server and spoof the IP address. Other users' processes that try to steal your port are automatically killed.
Getting started
To get started, please create a system user on the wcenter website (http://wcenter.djangohosting.ch/). After this is done and the system user is activated, you can add your domains on wcenter's domain page. Make sure you set the DNS servers of your domains properly. If you don't own a domain, you can create a free domain ending in ".sites.djangohosting.ch". Simply add a domain called "yoursite.sites.djangohosting.ch".
Your home directory
Before you start setting up your Django, please take a look at your home directory. You can find the following files in there:
- ~/init/
-
This is similar to the /etc/init.d directory found on most Linux distributions. It contains files that are used to start, stop, restart or reload services. Each file you put into this directory will be invoked when the machine shutting down or starting up (which will hopefully seldom happen). The script is passed one argument, which can be start to start the service or stop to stop the service. Of course, you can also add custom actions like restart or reload.
- ~/init/django
An example script (which will not run because it is not executable) that shows how to run Django with fastcgi.
- ~/init/lighttpd
-
This script allows you to start, stop, restart or reload the configuration of your personal lighttpd server. Here's how you use it:
Start lighttpd:
~/init/lighttpd start
Stop lighttpd:
~/init/lighttpd stop
Restart (stop and start) lighttpd:
~/init/lighttpd restart
Reload lighttpd's configuration:
~/init/lighttpd reload
- ~/lighttpd/
-
This is where lighttpd-specific files are stored.
- ~/lighttpd/lighttpd.conf
-
The main lighttpd configuration file.
- ~/lighttpd/port.conf
-
The local port on which lighttpd will listen on can be set here.
- ~/lighttpd/django.conf
-
Django installations which are created by the one-click Django installer are listed here.
- ~/lighttpd/lighttpd.pid
-
The PID (process ID) file of your lighttpd. You may have to deal with this file if your lighttpd got killed and didn't delete the file. In such a case, delete the PID file (but do not delete it while lighttpd is running).
- ~/public_html/
-
This directory is preferred for static websites.
- ~/private/
-
Here you can put your private data.
Of course you are free to delete any of these files and directories if you're sure that you don't need them. If you messed something up or need the files again, you can copy them back from the /etc/skel directory.
Automatic lighttpd configuration and Django installation
In wcenter, click on the Install Django site, adjust the default settings to your needs and then click on the button to start the installation. This will automatically set up lighttpd (if not done before) and install Django. It couldn't be simpler! Let's see in detail what is done:
- It is checked whether your lighttpd is already configured by looking at the ~/lighttpd/port.conf file. If the port is not set, a local port for the lighttpd is automatically created in wcenter and the configuration file is updated.
- A local port for the Django development server of your new site is created in wcenter.
- Website proxies for both the deployment and development URL of your Django site are set up, so requests to the development address (dev.yoursite.com) are redirected to the development server and requests your Django site (yoursite.com) are redirected to your lighttpd. This includes setting up the DNS records.
- A Django installation from SVN is copied into ~/django-projectname.
- The Django project is set up in ~/projectname.
- A start script for the development server is placed in ~/projectname/RUN which allows you to start the development server easily.
- Lighttpd's Django configuration file (~/lighttpd/django.conf) is updated appropriately.
- A Django start script is placed in ~/init/projectname.
- If you decide to use a database, it is automatically created and configured in your project's settings. Also, Django's syncdb function is called and the admin user is set up.
- Your lighttpd is reloaded and the Django start script is launched, so your new Django site is online immediately.
- Finally, you receive an e-mail which lists all the important details about your new Django site.
