Installing LibreGeoSocial is as easy as install a django application, but it is important to know that LibreGeoSocial is using GeoDjango, that implies using a spacial database. We strongly recommend PostgreSQL + PostGIS because it has the best support for the geoquerys we are using.
For more details about how to install a django server, please see django documentation.
Following, a list of different packages that you should have installed in your system, in order to run LibreGeosocial properly:
* postgresql
* postgresql-client-8.3
* postgresql-client-common
* postgresql-8.3-postgis
* python-psycopg2
* python-simplejson
* python-docutils
* python-json
* python-django
* python-imaging
* apache2
* libapache2-mod-python
(Packages names from Ubuntu, you should find similar packages in your distribution)
We have detected some problems with different versions of postgres and libgeos library. We recommend the next versions:
postgresql 8.3.9-0lenny1
postgresql-8.3 8.3.9-0lenny1
postgresql-8.3-postgis 1.3.3-3
libgeos-3.1.0 3.1.0-1~bpo50+1
libgeos-c1 3.0.0-5
First, downloading the source code of subversion repository:
$> cd /var/www/
$> svn co https://svn.morfeo-project.org/svn/libregeosocial/LibreGeoSocial/trunk/
$> mv trunk/ libregeosocial/
$> sudo chown -R www-data:www-data libregeosocial/
It is important to be aware about creating a spatial database. In geodjango documentation there are instructions that explain how to create it under all supported databases. If you are using PostrgreSQL + PostGIS you can follow Geodjando instructions or you can directly create a template using this instructions:
# log in to the database template1:
$> psql -U postgres -d template1
# issue command to create new database:
template1=# create database social with template = template1;
# update pg_database table to indicate that new database is a template
template1=# UPDATE pg_database SET datistemplate = TRUE where datname = 'social';
# connect to new database
template1=# \c social
# add PostGIS extensions and grant access to everyone to spatial tables.
social=# CREATE LANGUAGE plpgsql ;
social=# \i /usr/share/postgresql-8.3-postgis/lwpostgis.sql;
social=# \i /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql;
social=# GRANT ALL ON geometry_columns TO PUBLIC;
social=# GRANT ALL ON spatial_ref_sys TO PUBLIC;
If you use Ubuntu 10.4, you can find the scripts in the next path:
social=# \i /usr/share/postgresql/8.4/contrib/postgis.sql;
social=# \i /usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql;
if you use Debian Sid, you can find the scripts in the next path:
social=# \i /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql;
socual=# \i /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql;
Maybe you will need to set a password for the postgres user:
$> psql -U postgres
$> \password postgres
Configure correctly the settings.py file:
DATABASE_ENGINE = 'postgresql_psycopg2'
DATABASE_NAME = 'social'
DATABASE_USER = 'postgres' # Not used with sqlite3.
DATABASE_PASSWORD = 'postgres' # Not used with sqlite3.
DATABASE_HOST = 'localhost'
DATABASE_PORT = ''
Now, we run syncdb as postgres user to configurate the BBDD:
$> su postgres
$> cd /var/www/libregeosocial/
$> python manage.py syncdb
It’s necessary configurate Apache2 server because LibreGeoSocial uses https connections for login and normal connections for the rest of the petitions.
First, enable SSL connections:
# SSL module of Apache
libregeosocial:/etc/apache2/mods-available# a2enmod ssl
Enabling module ssl.
# Create self-signed certificates
$> cd /etc/apache2/ssl
$> openssl genrsa -des3 -out server.key 1024
$> openssl req -new -key server.key -out server.csr
$> openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
More infomation about self-signed certificates, visit http://www.akadia.com/services/ssh_test_certificate.html>.
Enable rewrite module in apache:
$> cd /etc/apache2/mods-available
$> a2enmod rewrite
Enabling module rewrite.
We create two virtualhost necessary for LibreGeoSocial. We suppose the next domain for the example: libregeosocial.yourdomain.com
File: 002-libregeosocial.yourdomain.com:
$> cd /etc/apache2/sites-available
$> vi 002-libregeosocial.yourdomain.com
NameVirtualHost libregeosocial.yourdomain.com:80
ServerAdmin webmaster@localhost
DocumentRoot /var/www/libregeosocial/
ServerName libregeosocial.yourdomain.com
RedirectMatch ^/(social/user/login/) https://libregeosocial.yourdomain.com/$1
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonPath "['/var/www/libregeosocial/'] + sys.path"
PythonDebug On
ErrorLog /var/log/apache2/error.log
Alias /media /usr/share/python-support/python-django/django/contrib/admin/media
SetHandler None
SetHandler None
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
File: 003-https.libregeosocial.yourdomain.com:
$> cd /etc/apache2/sites-available
$> vi 003-https.libregeosocial.yourdomain.com
NameVirtualHost *:443
ServerAdmin webmaster@localhost
DocumentRoot /var/www/libregeosocial/
ServerName libregeosocial.yourdomain.com
RewriteEngine on
RewriteCond "%{REQUEST_URI}" "!^/social/user/login/$"
RewriteRule "^/(.*)" http://libregeosocial.yourdomain.com/$1 [L]
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonPath "['/var/www/libregeosocial/'] + sys.path"
PythonDebug On
ErrorLog /var/log/apache2/error.log
Alias /media /usr/share/python-support/python-django/django/contrib/admin/media
SetHandler None
LogLevel warn
CustomLog /var/log/apache2/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
SSLProtocol all
Enabled the virtual sites:
$> cd /etc/apache2/sites-available
$> a2ensite 002-libregeosocial.yourdomain.com
Enabling site 002-libregeosocial.yourdomain.com
$> a2ensite 003-https.libregeosocial.yourdomain.com
Enabling site 003-https.libregeosocial.yourdomain.com
# Restart apache
$> /etc/init.d/apache2 restart
In order to access to nodes information you need to create the layers data base. There is a python script to manage this task under: social.layers.LayersConsistency, you should invoke this script inside django instance:
$> python2.5 manage.py shell
shell> from social.layers import LayerConsistency
shell> LayerConsistency.main()
This script generate the layers database and the user for layers management (social.layers.config.LAYER_MANAGER) with the default password “admin”. Please, change this password as soon as possible.
Also, LibreGeoSocial will made use of several functions in the database:
psql -U postgres social < pl_functions.sql
Finally, the system needs to have an anonymous user. Create this user, you can do it with the web interface:
https://libregeosocial.yourdomain.com/social/
Ready! You can test the instalation with this URI:
https://libregeosocial.yourdomain.com/social/
See the “External Applications” section to add more funcionality in LibreGeoSocial.
Please, if you find any problems installing LibreGeoSocial or you do not understand this instructions, feedback is welcome at our developer list.
It is also very important to read how to manage DDBB consistency between different server versions (regarding data models): South for DDBB consistency