Installing Movim on PostgreSQL

Introduction

Do you know Movim? You should take a look if you’re interesting in social network that are trying to take care of your privacy. With it, you own your data.

OK, that’s great…​ but that means that you must install it on your server. Let’s do it!

Thie article will explain how to install the last unstable version of movim, 0.8alpha12 at this time (but it should work with stable versions too), on a Debian server runned with Apache 2. We will use PostgreSQL as the database management system. It is mainly based on the installation guide of Movim.

Prepare the database management system

After installing PostgreSQL on the system, we will prepare it. The goal is to create one user especially for the Movim web application which will have his own database and nothing else.

Create the movim user

First, connect yourself as the postgres user which will allow you to send requests to the PostgreSQL engine.

	su - postgres

Then you should be able to create the user. Either you enter the PostgreSQL engine to create the user (and you should find the right SQL command to do it), or you use the facility createuser. We will create a user with no rights to create database or users and with no superuser rights. We’ll put no password since we will connect from the localhost (see next sections for allowing connections from localhost). Adding the --echo option will allow you to see what should be the SQL commands to send.

	createuser --no-createdb --echo --encrypted --inherit --login --no-createrole --no-superuser movim

Create the movim database

For the Movim web application, a dedicated database, called movim will be created. We must associate it to the user movim and we will use the a unicode encoding (see PostgreSQL documentation). To create the database, you can use the createdb facility. The last field can be used to add a description.

	createdb --echo --encoding=Unicode --owner=movim movim "Movim social network database"

Giving correct rights

The database and the web application will be hosted on the same server. We don’t need a password for the web application to connect to the database; we will only trust any connection to the movim database system from movim user on the localhost (see PostgreSQL documentation).

The Debian documentation help to understand where to begin. We will edit the file /etc/postgresql/x.y/main/ph_hba.conf and add 2 lines (one for IPv4 and one for IPv6) to allow connection from localhost with movim user on movim database.

	# DO NOT DISABLE!
	# If you change this first entry you will need to make sure that the
	# database superuser can access the database using some other method.
	# Noninteractive access to all databases is required during automatic
	# maintenance (custom daily cronjobs, replication, and similar tasks).
	#
	# Database administrative login by Unix domain socket
	local   all             postgres                                peer
# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 and IPv6 local connections for Movim
host    movim           movim           127.0.0.1/32            trust
host    movim           movim           ::1/128                 trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Bonus

You may want to see what’s in the database. You should connect as the postgres user then run psql.

In the PostgreSQL shell, you may try \l to list all the databases. Then you may try other commands considering the documentation.

Installing Movim

You did the hard part, installing Movim is very easy. First, download it on the website. Then unzip it in the directory yuo want (don’t forget to create a entry with Apache).

Now, you need to configure the database for your Movim instance. In the unzipped archive, you’ll find a config/db.example.inc.php. Copy this file in config/db.inc.php then edit it. You should be able to modify it yourself without explanation (but I will help you, the following file).

	<?php
	# This is the database configuration of Movim
	# You need to copy an rename this file to 'db.inc.php' and complete the values
	$conf = array(
		# The type can be 'pgsql' or 'mysql'
		'type'        => 'pgsql',
		# The database username
		'username'    => 'movim',
		# The password
		'password'    => '',
		# Where can we find the database ?
		'host'        => 'localhost',
		# The port number, 3306 for MySQL and 5432 for PostGreSQL
		'port'        => 5432,
		# The database name
		'database'    => 'movim'
	);

Now, you should be able to access your website.

References

links

social