Meego Wiki
Views

Quality/QA-tools/OTS/Plugins/Django

From MeeGo wiki
(Difference between revisions)
Jump to: navigation, search
(Enable/disable Django applications)
(Enable/disable Django applications)
Line 28: Line 28:
== Enable/disable Django applications ==
== Enable/disable Django applications ==
-
In '''0.8.3''' release, this is not necessary anymore. Plug-ins are loaded automatically.
+
From '''0.8.3''' release, this is not necessary anymore. Plug-ins are loaded automatically.
1. Edit Django settings
1. Edit Django settings

Revision as of 11:45, 13 May 2011

Contents

Django environment setup

Introduction

Django is used for handling database communication and displaying WebUI.

Basic installation

These instructions are made for Ubuntu, but should work in the same principals with other distributions.
Installation is made to OTS server.

1. Install django

sudo apt-get install python-django

In Fedora:

sudo yum install Django

2. Download the latest django xml-rpc plugin

https://launchpad.net/django-xmlrpc

3. Install django plug-in

tar xzf django_xmlrpc-0.1.tar.gz
sudo mv django_xmlrpc /usr/local/lib/python2.6/dist-packages/

In Fedora (as root):

mv django_xmlrpc /usr/lib/python2.6/site-packages/
chcon -R -t httpd_user_content_t /usr/lib/python2.6/site-packages/django_xmlrpc
chcon -R -t httpd_user_content_t /opt/ots
setsebool -P httpd_unified 1
setsebool -P httpd_tmp_exec 1

Enable/disable Django applications

From 0.8.3 release, this is not necessary anymore. Plug-ins are loaded automatically.

1. Edit Django settings

sudo nano /usr/local/lib/python2.6/dist-packages/ots/django/settings.py

In Fedora:

sudo nano /usr/lib/python2.6/site-packages/ots/django/settings.py

2. Comment/uncomment OTS components in 'INSTALLED_APPS' section

# OTS components:
'ots.plugin.logger',
'ots.plugin.monitor',
'ots.plugin.history'

Create/update databases

1. Create database

sudo python /usr/local/lib/python2.6/dist-packages/ots/django/manage.py syncdb --settings=settings

In Fedora:

 sudo python /usr/lib/python2.6/site-packages/ots/django/manage.py syncdb --settings=settings

2. Set permissions to database file

sudo chown www-data:www-data /opt/ots
sudo chown www-data:www-data /opt/ots/ots.sqlite

In Fedora:

sudo chown apache:apache /opt/ots
sudo chown apache:apache /opt/ots/ots.sqlite

Apache configuration

1. Install Apache2 and Apache2 modules

sudo apt-get install libapache2-mod-wsgi apache2-mpm-prefork

Fedora:

yum install httpd mod_wsgi
rm /etc/httpd/conf.d/welcome.conf

2. Apache2 configuration

Ubuntu 10.04

sudo apt-get install libapache2-mod-python
<VirtualHost *:80>

AliasMatch /([^/]*\.css) /var/www/styles/$1

Alias /media/ /var/www/media/

<Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE ots.plugin.logger.django_ots.settings
    PythonDebug On
</Location>

<Location "/media">
    SetHandler None
</Location>

<LocationMatch "/styles">
    SetHandler None
</LocationMatch>
</VirtualHost>

Ubuntu 10.10

sudo nano /etc/apache2/sites-enabled/000-default
<VirtualHost *:80>

        AliasMatch /([^/]*\.css) /var/www/styles/$1

        Alias /media/ /var/www/media/

        <Directory /usr/local/wsgi/static>
                Order deny,allow
                Allow from all
        </Directory>

        WSGIScriptAlias / /var/www/ots.wsgi

        <Directory /usr/local/wsgi/scripts>
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

Fedora

rm /etc/httpd/conf.d/welcome.conf
sudo nano /etc/httpd/conf.d/ots.conf 
<VirtualHost *:80>

        AliasMatch /([^/]*\.css) /var/www/styles/$1

        Alias /media/ /var/www/media/

        <Directory /usr/local/wsgi/static>
                Order deny,allow
                Allow from all
        </Directory>

        WSGIScriptAlias / /var/www/ots.wsgi

        <Directory /usr/local/wsgi/scripts>
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

3. Copy www files to /var/www/

sudo cp -r /usr/share/ots/django/* /var/www/
sudo cp -r /usr/share/ots/plugin/* /var/www/

4. Add WSGI settings "WSGIRestrictSignal Off"

sudo nano /etc/apache2/apache2.conf

Fedora:

sudo nano /etc/httpd/conf/httpd.conf

5. Restart apache

sudo service apache2 restart

Fedora:

chkconfig --add httpd
chkconfig httpd on
/etc/init.d/httpd start
Personal tools