.. _install:

============
Installation
============

Source installation
===================

Download the `Baruwa <http://pypi.python.org/pypi/baruwa>`_ source
and untar it::

    # tar xzvf baruwa-<version>.tar.gz
    # cd baruwa-<version>

Make sure you have the required packages installed as well as a working
MailScanner :ref:`setup <mailscanner>` then proceed. The following commands 
should be run as a privileged user.

**Create the database**::

    # mysqladmin -u root -p create baruwa

**Create a Mysql user for baruwa**

Run the command from the mysql prompt::

    mysql> GRANT ALL ON baruwa.* TO baruwa@localhost IDENTIFIED BY '<password>';
    mysql> flush privileges;

**Install Baruwa**

Run::

    # python setup.py install

**Configure the Baruwa settings**

Edit the Baruwa settings.py file::

	# baruwa_path=$(python2.4 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")
	# vi $baruwa_path/setttings.py
	
Set the following options::

    DATABASE_NAME = 'baruwa'
    DATABASE_USER = 'baruwa'
    DATABASE_PASSWORD = '<password>'
    DATABASE_HOST = 'localhost'

Populate the database and create admin user::

	# $baruwa_path/baruwa/manage.py syncdb
	
The syncdb command populates your SQL database and allows you 
to create the admin user.

Edit the settings.py file and make the baruwa specific changes to suit
your install::

	# vi $baruwa_path/setttings.py

Link to the dojo toolkit::

	# ln -s /path/to/dojo $baruwa_path/baruwa/static/js
	# ln -s /path/to/dojox $baruwa_path/baruwa/static/js
	# ln -s /path/to/dijit $baruwa_path/baruwa/static/js

**Setup Web server**

    **Apache/mod_wsgi**

    Make sure mod_wsgi is enabled, uncomment the following line in
    /etc/httpd/conf.d/wsgi.conf::

        LoadModule wsgi_module modules/mod_wsgi.so
    
    Use the sample configuration provided (extras/baruwa-mod_wsgi.conf) 
    as a template. Copy to your apache configuration directory usually
    /etc/httpd/conf.d

    Make sure that your apache is configured for name based virtual
    hosting such that you can run other sites on the same box if you
    wish to.

    Edit /etc/httpd/conf.d/baruwa-mod_wsgi.conf and set ServerName to
    the hostname you will use to access baruwa

    Restart apache for the configuration to take effect.::

        # /etc/init.d/httpd reload

    **Lighttpd**

    Use the generic django instructions at 
    http://docs.djangoproject.com/en/1.1/howto/deployment/fastcgi/#lighttpd-setup

    **Nginx**

    Use the nginx instructions at http://wiki.nginx.org/NginxDjangoFastCGI

    **Cherokee**

    Use the cherokee cookbook instructions at http://www.cherokee-project.com/doc/cookbook_django.html

.. _setupmailscanner:


**Thats it**

Point your browser to http://hostname_used login with admin user and password
and start working. You can now use the interface to add users, domains and 
process messages, etc etc.

Distribution / OS installation
==============================

    + :ref:`installcentos`.
    + :ref:`installfedora`.
    + :ref:`installdeb`.

