Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
A high-level Web framework is software that eases the pain of building dynamic Web sites. It abstracts common problems of Web development and provides shortcuts for frequent programming tasks.
Django grew organically from real-world applications written by a Web development team in Lawrence, Kansas. It was born in the fall of 2003, when the Web programmers at the Lawrence Journal-World newspaper, Adrian Holovaty and Simon Willison, began using Python to build applications.
Django is now an open source project with contributors across the planet, the original World Online developers still provide central guidance for the framework’s growth, and World Online contributes other important aspects such as employee time, marketing materials, and hosting/bandwidth for the framework’s Web site
Django was designed to handle two challenges: the intensive deadlines of a newsroom and the stringent requirements of the experienced Web developers who wrote it. It lets you build high-performing, elegant Web applications quickly.
How we can setup Django in cPanel Server?
In order to setup Django, there are certain server requirements. Lets move on to that.
Being a Python Web framework, Django requires Python.
It works with any Python version from 2.4 to 2.6 (due to backwards incompatibilities in Python 3.0, Django does not currently work with Python 3.0 ).
Before installing Python, its dependencies needed to be installed in the server.
Installing Python 2.5 dependencies
$ wget http://www.sqlite.org/sqlite-amalgamation-3.6.4.tar.gz
Install Python 2.5
Download Python 2.5 source package, unzip, and enter working directory:
Configure Python 2.5 so that we're not overwriting the system's python installation:
$ ./configure --prefix=/opt/python2.5 --with-threads --enable-shared
Make and install:
Add an alias to root's .bash_profile:
Make a symbolic link:
$ ln -s /opt/python2.5/bin/python /usr/bin/python2.5
Configure ld to find your shared libs:
$ cat >> /etc/ld.so.conf.d/opt-python2.5.conf
Test python 2.5 installation:
You should get an interactive Python 2.5 session like:
Python 2.5 (r25:51908, Nov 9 2008, 23:18:24)
Setuptools is a Python module that helps to compile, distribute and install Python packages by wrapping them into "egg"s. Eggs contain additional information to process dependencies, etc.
Install MySQLdb package:
If you plan to use Django’s database API functionality, you’ll need to make sure a database server is running. Django supports many different database servers and is officially supported with PostgreSQL, MySQL, Oracle and SQLite (although SQLite doesn’t require a separate server to be running).
In addition to a database backend, you’ll need to make sure your Python database bindings are installed.
Here we go for MySQL, hence we need MySQLdb
Verify Python 2.5 Installation:
In order to use Django on a production site, use Apache with mod_wsgi. The mod_wsgi is similar to mod_perl – it embeds Python within Apache and loads Python code into memory when the server starts. Code stays in memory throughout the life of an Apache process, which leads to significant performance gains over other server arrangements. Make sure you have Apache installed, with the mod_wsgi module activated. Django will work with any version of Apache that supports mod_wsgi.
Configure mod_wsgi to link with Python 2.5 shared libs:
$ cd /opt/python2.5/lib/python2.5/config
Make and install:
Add mod_wsgi to Apache 2.x:
Simply add these lines in the apache configuration file.
LoadModule wsgi_module /usr/local/apache/modules/mod_wsgi.soSetup a Django 1.0 test project
Create a new user/domain via WHM/cPanel
Edit users .bash_profile:
Create a new project directory:
$ mkdir -p /home/username/sites/domain.com
Create your apps .wsgi script:
$ pico /home/username/public_html/test.wsgi
$ chown username: /home/username/public_html/test.wsgi
Setup a vhost include (as root)
$ mkdir -p /usr/local/apache/conf/userdata/std/2/username/domain.com
WSGIScriptAlias / /home/username/public_html/test.wsgi
# This fixes the broken ErrorDocument directive we inherit that breaks auth
domain.com should now be serving a django site.
To restart a django instance:
$ touch ~/public_html/test.wsgi
|Others in this Category|
|Apache failed to start with the "No space left on device" error.|
|Fsck.ext3: Unable to resolve UUID|
|Upgrading Openssh on CentOS And Chrooting a User When Connecting via SFTP|