Lighttpd configuration
If you decide to set up lighttpd manually for some reason, you need to create a local port on the wcenter website. Then, open the ~/lighttpd/port.conf file and add the following line (replace 0 with the port number of the local port you just created):
server.port = 0
Now, you can launch lighttpd using the following command:
~/init/lighttpd start
If you want to redirect requests to any of your domains to your personal lighttpd, you have to set up a website proxy in wcenter and specify the port of the lighttpd.
Django setup
If you haven't already set up lighttpd as described before, please do that now. To set up Django, create a local port for the Django development server in the wcenter web interface. Then, also in wcenter, create two website proxies: The first one is for the Django development server (e.g. on dev.yourdomain.com) which should point to the port you just created for Django. The second one is for the actual Django site and should point to the port of your lighttpd.
You can find the latest Django trunk (SVN) in /usr/share/django. Other branches can be found in /usr/share/django-svn/. These directories are updated every night. Using the trunk directly from that directory is great for testing your sites using Django's built-in development server. However, if you want to deploy a production site, do not rely on the nightly trunk, as your application will stop working sooner or later, because there might be backwards-incompatible changes to Django. This is why it is highly recommended to use a separate SVN checkout (which will also allow you to integrate custom patches).
The best way to get started is to check out the latest SVN or to use the latest stable release (or its corresponding branch, e.g. branches/0.96-bugfixes for 0.96). To download your own Django version, simply follow the instructions on http://www.djangoproject.com/download/. For example, to check out the latest Django trunk, use the following command:
svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk
You will find the source in a directory called django-trunk. Alternatively, you can copy the files from the /usr/share/django* directories into your home.
To tell Python which Django should be used, simply set the environment variable PYTHONPATH. For example, use the following command to run the development webserver, assuming you want to use the Django which is in the django-trunk directory in your home:
PYTHONPATH=~/django-trunk python manage.py runserver port
Replace port with the port number which you set up for your Django development server.
Run Django + fastcgi
We prepared a Django start script for you which automatically runs Django in fastcgi-mode so it can be used with lighttpd. To set it up, copy it, make it executable and adjust the name and path of your site:
cd ~/init cp django mysite chmod +x mysite
Now open mysite and adjust the settings to your needs. For example, if your site is called mysite, your Django project is in the directory ~/mysite_project and your Django installation is in ~/mysite_django, you can use the following settings:
NAME="mysite" PROJECT_DIR="$HOME/mysite_project" SETTINGS="settings" PYTHONPATH="$HOME/mysite_django"
To start your Django site, use:
~/init/mysite start
Note that when you start or restart Django it may take up to 5 seconds until your site is accessible if someone tried to access it recently. This is due to a fixed timeout in lighttpd's source code.
Set up your Django site in lighttpd
The lighttpd configuration is located in ~/lighttpd/lighttpd.conf. If you haven't set the port number yet, make sure you do that as described in the lighttpd configuration section.
To set up a Django site you can use the following snippet:
$HTTP["host"] =~ "(^|\.)mydomain\.com$" {
fastcgi.server = (
"/django.fcgi" => (
"main" => (
"socket" => env.HOME + "/mysite_project/mysite.sock",
"check-local" => "disable",
)
),
)
alias.url = (
"/media" => env.HOME + "/mysite_project/media",
)
url.rewrite-once = (
"^(/media.*)$" => "$1",
"^/favicon\.ico$" => "/media/favicon.ico",
"^(/.*)$" => "/django.fcgi$1",
)
}
Simply paste it at the end of the lighttpd configuration file. Replace mydomain\.com with the name of your domain. Be sure to escape all dots of your website's name (put a backslash before it: \.). Replace your_django_project/media with the path of you Django media directory (relative to your home directory). Replace mysite_project/mysite.sock with the path to your fastcgi socket file (if you are using the Django init script, you should replace the mysite in mysite.sock with the name of the site you specified in the init script).
Now you can launch your lighttpd:
~/init/lighttpd start
Whenever you make changes to the configuration, you can reload the configuration or restart lighttpd:
~/init/lighttpd reload
~/init/lighttpd restart
