http://www.alwaysdata.com
(10M free. more than enough to write lots of code, and you have ssh access too!)
Now, to get your free Django to work, it is very easy by just following their (non-English) wiki.
http://wiki.alwaysdata.com/wiki/D%C3%A9ployer_une_application_Django
You will need two files, django.fcgi, and .htaccess on this shared hosting environment.
(You can copy and paste the two files below)
django.fcgi.htaccess
#------------------------------------------------------
#!/usr/bin/python
import os, sys
_PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, _PROJECT_DIR)
sys.path.insert(0, os.path.dirname(_PROJECT_DIR))
_PROJECT_NAME = _PROJECT_DIR.split('/')[-1]
os.environ['DJANGO_SETTINGS_MODULE'] = "%s.settings" % _PROJECT_NAME
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
#-------------------------------------------------------
AddHandler fcgid-script .fcgi---------------------------------------------------------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]
1. Create your Django project. django-admin.py startproject mysite
2. Create a "public" directory under "mysite"
3. put django.fcgi and .htaccess under the public directory
Your "mysite" structure will look like this:
myproject/
__init__.py
manage.py
public/
django.fcgi
.htaccess
media/
settings.py
urls.py
myapp/
views.py
models.py
Notice the media directory under public, you can create a soft link for that with
ln -s /var/lib/python/django/1.1/django/contrib/admin/media/ media
so, you can get the Django admin to work properly, i
it's django version 1.1 in this case.
Then, your "public" url is under Django's control!
http://youraccount.alwaysdata.net/mysite/public/
e.g. If you follow the hello world example in the Django book, you can go
http://youraccount.alwaysdata.net/mysite/public/hello
and it will print the happy Django's "hello world".
Last step:
Make sure you go to your administration panel. Go to domain, edit, and change your root directory to, for example, /www/mysite/public/
or people can view your source code :)
So you can use your free Django powered site with
http://youraccount.alwaysdata.net/hello
Deployment:
tar your entire site and upload with ftp, and then untar.
remember to update the "TEMPLATE_DIRS" (using ABSOLUTE path), and update the "DATABASE_NAME" (using ABSOLUTE path if using sqlite)
also read:
http://www.codekoala.com/blog/2008/installing-django-shared-hosting-site5/
http://www.ibm.com/developerworks/opensource/library/os-django/index.html
No comments:
Post a Comment