Skip to content

Latest commit

 

History

History
249 lines (216 loc) · 11.9 KB

README.nginx.markdown

File metadata and controls

249 lines (216 loc) · 11.9 KB

An Introduction to KLP

The Karnataka Learning Partnership (KLP) aims to be a partnership of NGOs across Karnataka with these objectives:

  • Create a space where all information pertaining to all children across the state should be made available. This means that it will be our endeavour to work closely with a large number of local NGOs across the state so that they become the channel to collect and update information on a regular basis.
  • Get all children in Karnataka on this database within the next 3-5 years in a phased manner.
  • Give other NGOs the ability to input data pertaining to their programmes as a layer of information on the KLP site. For example, Agastya International and Akshaya Patra both serve the same constituency as klp does - if they have access to child databases, then we avoid duplication of efforts and they can use the data for their own interventions and share it on the KLP site.
  • Prepare constituency-wise reports for every elected representative - Members of Parliament, Members of the Legislative Assembly ; Corporators and Panchayat members. This will enable these elected representatives push for an effective agenda for education across the state.
  • Help teachers and head-teachers generate accurate data for DISE reports in a timely manner. This would cover infrastructure of the schools / centres and also the learning outcomes for children.
  • Provide the average citizen adequate information on issues pertaining to education in the state. It is our expectation that those who are on-line and visitors to KLP will find this site informative and that they would be enthused enough to add more data to the site. Over time, we hope that the participation of the community would help in catalyzing and driving demand for quality in education throughout the state.
  • Provide good data to decision makers in government for making effective decisions on investments required for schools across the state. Also, help decision makers at various levels determine where remedial help is required the most and what capacity building needs to be done at different levels.
  • Engage the academic community to use the data and provide analyses that would help in driving policy reforms to provide effective and inclusive education to all children.

We believe that if we all work together, it is possible for us to bring in higher levels of quality in our primary education system through a comprehensive use of governance. Nearly 80% of the children in our state use the government primary school system and it is here that, with all our support, we can ensure maximum public good.

Vision

Karnataka Learning Partnership is a public space where all citizens can contribute to the cause of ensuring better schools and schooling for our children . Better education will ensure better human development and prosperity for our citizens.

The KLP MIS

We like to be honest with ourselves as to efficacy and impact of our programmes and the best way that we have found is to collect hard assessment data that we subsequently analyse. This is a challenging task as it requires technology as well as some robust, yet simple processes around the technology.

Since 2006, the klp Foundation has become increasingly experienced on how best to perform the task laid out above. We are now in a position to design an MIS platform that is sufficiently generic to be used in other organisations in the education sector and perhaps even other sectors.

The KLP MIS / EMS components

  • Users
  • Boundaries
  • Institutions
  • Institution Members
  • Institution Owners
  • Programmes
  • Assessments

Set up of the Development Environment

In any new environment as SUDO USER, run the following commands
[sudouser@server:~]$ sudo apt-get install python-setuptools python-dev build-essential
[sudouser@server:~]$ sudo apt-get install libpcre++-dev git gitosis libxml2-dev libssl-dev
[sudouser@server:~]$ sudo easy_install -U pip
[sudouser@server:~]$ sudo pip install -U virtualenv
[sudouser@server:~]$ sudo adduser klpdemo
[sudouser@server:~]$ su - klpdemo

Database related installation

In any new environment as SUDO USER, run the following commands
[sudouser@server:~]$ apt-get install postgresql-server-dev-8.4 libpq-dev

Set up a Virtual Python environment

[klpdemo@server:~]$ virtualenv --no-site-packages klpsite
[klpdemo@server:~]$ cd klpsite
[klpdemo@server:~]$ . bin/activate
Note that the prompt changes after activating to %(klpsite)klpdemo%>
Install all required dependencies at this prompt.
[(klpsite)klpdemo@server:~]$ pip install PIL
[(klpsite)klpdemo@server:~]$ pip install Django==1.2.5

Database related installation

[(klpsite)klpdemo@server:~]$ pip install psycopg2

Set up Django and WSGI

At the prompt %(klpsite)klpdemo%>, run the following commands while in the ~/klp directory If you are a collaborator on this private repository, clone the Git Repo into your home folder on the installation box at the prompt %home/miscollabrator%>.
[miscollaborator@server:~]$ git clone git://github.com/klpdotorg/KLP-MIS.git
Now copy the checkout folder at the prompt %(klpsite)klpdemo%/home/klp>
[(klpsite)klpdemo@server:~]$ cp -r /home/miscollaborator/KLP-MIS/klp ~/klpsite/
[(klpsite)klpdemo@server:~]$ cd ~/klpsite/klp
[(klpsite)klpdemo@server:~]$ vi klp.wsgi
The content of this file should be:

import sys
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
sys.path.append('/home/klpdemo/klpsite/klp/lib/python2.6/site-packages')
sys.path.append('/home/klpdemo/klpsite/klp/lib/python2.6/lib-dynload')
sys.path.append('/home/klpdemo/klpsite/klp/lib/python2.6')
sys.path.append('/home/klpdemo/klp')
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'klp.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Configuration in settings.py

The content of settings.py file in should carry Postgres DB details:
[(klpsite)klpdemo@server:~]$ cd ~/klp/
[(klpsite)klpdemo@server:~]$ vi settings.py

DATABASES = {
'default': {
'ENGINE': 'postgresql_psycopg2'
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
Additionally make sure the directory path to the Django installation is correctly indicated, for eg in the line:
TEMPLATE_DIRS = (
'/home/klpdemo/klpsite/klp/schools/templates/',
)

Set up Nginx and uWSGI

[(klpsite)klpdemo@server:~]$ mkdir programs
[(klpsite)klpdemo@server:~]$ cd programs
[(klpsite)klpdemo@server:~]$ wget http://nginx.org/download/nginx-0.8.53.tar.gz
[(klpsite)klpdemo@server:~]$ wget http://nginx-init-ubuntu.googlecode.com/files/nginx-init-ubuntu_v2.0.0-RC2.tar.bz2
[(klpsite)klpdemo@server:~]$ wget http://projects.unbit.it/downloads/uwsgi-0.9.6.5.tar.gz
[(klpsite)klpdemo@server:~]$ tar xvf nginx-0.8.53.tar.gz
[(klpsite)klpdemo@server:~]$ tar xvf uwsgi-0.9.6.5.tar.gz
[(klpsite)klpdemo@server:~]$ mkdir ~/nginx
[(klpsite)klpdemo@server:~]$ cd nginx-0.8.53
[(klpsite)klpdemo@server:~]$ ./configure --without-http_uwsgi_module --add-module=../uwsgi-0.9.6.5/nginx/ --prefix=/home/klpdemo/nginx

Disable unbuilt uWSGI(thats old) and includes latest uwsgi package
[(klpsite)klpdemo@server:~]$ make
[(klpsite)klpdemo@server:~]$ make install
[(klpsite)klpdemo@server:~]$ cd ../uwsgi-0.9.6.5
[(klpsite)klpdemo@server:~]$ make -f Makefile
[(klpsite)klpdemo@server:~]$ cp uwsgi ~/klp/bin/
[(klpsite)klpdemo@server:~]$ cp uwsgi_params ~/nginx/
[(klpsite)klpdemo@server:~]$ cd ~/nginx
[(klpsite)klpdemo@server:~]$ mkdir vhost
[(klpsite)klpdemo@server:~]$ vi ~/nginx/conf/nginx.conf

The content of this file should include vhost in the http context and make sure you comment out default 'location /' context in here

include vhost/*.conf;

Also change the content of the django.conf [(klpsite)klpdemo@server:~] vi nginx/vhost/django.conf
Add the django virtualhost config (Assuming 192.168.2.2 is the system ip)

upstream django {
ip_hash;
server 192.168.2.2:8010;
comment out:#server unix:sock/uwsgi.sock;
}
server {
listen 80;
server_name klp.mahiti.org;
location /static_media/ {
alias /home/klpdemo/klpsite/klp/static_media/;
}
location / {
uwsgi_pass django;
comment out:#uwsgi_param UWSGI_SCRIPT mcms.pac;
include uwsgi_params;
}
}

[(klpsite)klpdemo@server:~]$ cd ~/klpsite/klp
[(klpsite)klpdemo@server:~]$ uwsgi -s 192.168.2.2:8010 -M --wsgi-file klp.wsgi
Check if uwsgi runs without errors. Ctrl-C to exit.

Setup Supervisor

As ROOT user set up Supervisor:
[root@server:~]$ pip install supervisor
[root@server:~]$ echo_supervisord_conf > ~/etc/supervisord.conf
[root@server:~]$ vi ~/etc/supervisord.conf

Change supervisor sock and logs path to /home/klpdemo/klpsite/klp/logs
And add control for uwsgi

[group:klp-ems]
programs=uwsgi,nginx
[program:uwsgi]
command=/home/klpdemo/klpsite/klp/bin/uwsgi --socket 192.168.2.2:8010 --processes 5 --master --wsgi-file klp.wsgi
directory=/home/klpdemo/klpsite/klp/
user=klpdemo
autostart=true
autorestart=true
stdout_logfile=/home/klpdemo/klpsite/klp/logs/uwsgi.log
redirect_stderr=true
stopsignal=QUIT
[program:nginx]
command=/home/klpdemo/nginx/sbin/nginx -c /home/klpdemo/nginx/conf/nginx.conf -g "daemon off;"
directory=/home/klpdemo/
user= root
autostart=true
autorestart=true
stopsignal=QUIT

Download the init-script for supervisor to /etc/init.d/
[root@server:~]$ cd /etc/init.d
[root@server:~]$ wget -O supervisord http://svn.supervisord.org/initscripts/debian-norrgard
root@server:~]$ chmod +x supervisord

small changes in the script
check where the supervisord binary(command program) is installed
[root@server:~]$ which supervisord
In some cases maybe /usr/local/bin/supervisord or /usr/bin or /usr/sbin
[root@server:~]$ vi /etc/init.d/supervisord
Put the right path for supervisor in line 25 of the script.
Repeat this to correct the path of supervisorctl too.
Specify the full path at line 75 for supervisorctl.
Add a group for controlling ems:
[root@server:~]$ groupadd emsadmin
[root@server:~]$ usermod -a -G emsadmin klpdemo
[root@server:~]$ chgrp emsadmin /etc/supervisord.conf
[root@server:~]$ chmod 660 /etc/supervisord.conf
[root@server:~]$ vi /etc/supervisord.conf

Make sure the sock permssion is changed in the config as

[unix_http_server]
file=/tmp/supervisor.sock
chmod=0760

chown=root:emsadmin

Check if supervisor functions fine:
[root@server:~]$ /etc/init.d/supervisord restart
[root@server:~]$ su - klpdemo

[klpdemo@server:~]$ supervisorctl start klp-ems:uwsgi
[klpdemo@server:~]$ supervisorctl start klp-ems:nginx
[klpdemo@server:~]$ supervisorctl status
Check for:
klp-ems:nginx RUNNING pid 26046, uptime 0:13:19
klp-ems:uwsgi RUNNING pid 26036, uptime 0:13:52

Bringing up the Application

Now you should be having a django app rendered at http://<server_ip>:80/home/