Redmatrix Documentation

How to install the Redmatrix on a Raspberry Pi

You just bought a Raspberry Pi and want to run the RED Matrix with your own domain name?

Then this page is for you! You will:

  • Install Raspberry OS (Debian Linux) on a Raspberry
  • Install Apache Web Server, PHP, MaySQL, phpMyAdmin
  • Register a free domain (dynamic DNS) and use it for your hub
  • Install Redmatrix
  • Keep your Raspberry Pi and Redmatrix up-to-date
  • TODO Setting up SSL
  • TODO Running with SSL
  • TODO Make the webserver less vulnarable to attacks

1. Install Raspberry OS (Debian Linux)

instructions under
This page links to the quick start containing detailed instruction.

Format SD card

using the program gparted under Linux Mint 15

format as FAT32

Download NOOBS (offline and network install)


copy unzipped files to SD card

Install Raspbian as OS on the Rasperry Pi

connect with keyboard via USB

connect with monitor via HDMI

Insert SD card into Rasperry Pi

Connect with power supply to switch on the Rasperry

choose Raspbian as OS (> installs Raspbian....)

wait for the coniguration program raspi-config (you can later start it by sudo raspi-config)

Configure Raspbian

in raspi-config > advanced > choose to use ssh (!! You need this to connect to administrate your Pi from your PC !!)

in raspi-config > change the password (of default user "pi" from "raspberry" to your password)

in raspi-config (optional) > Internationalisation options > Change Locale > to de_DE.utf-8 utf-8 (for example)

in raspi-config (optional) > Internationalisation options > Change Timezoe > set your timezone

in raspi-config (optional) > Overlock > medium



sudo reboot

Now its time to connect the Pi to the network.

  • pull out keyboard
  • pull out monitor
  • you even can pull out the power supply (USB)
  • plug-in the network cable to the router
  • plug-in the power supply again
  • wait for a minute or to give the Pi time to boot and start ssh...

On your PC connect to the Pi to administrate (here update it).
Open the console on the PC (Window: Start > cmd, Linux: Shell)

Hint: use the router admin tool to find out the IP of your PIssh pi@
sudo apt-get update
sudo apt-get dist-upgrade


2. Install Apache Web Server, PHP, MaySQL, phpMyAdmin

Install Apache Webserver

sudo bash
sudo groupadd www-data
might exist already

sudo usermod -a -G www-data www-data
sudo apt-get update
sudo reboot

reconnect via ssh, example: ssh pi@
sudo apt-get install apache2 apache2-doc apache2-utils

Open webbrowser on PC and check
Should show you a page like "It works"


Install PHP, MaySQL, phpMyAdmin

sudo bash
apt-get install libapache2-mod-php5 php5 php-pear php5-xcache php5-curl
apt-get install php5-mysql
apt-get install mysql-server mysql-client
enter and note the mysql passwort

apt-get install phpmyadmin

Configuring phpmyadmin
- Select apache2
- Configure database for phpmyadmin with dbconfig-common?: Choose Yes


Test installation

cd /var/www

create a php file to test the php installationsudo nano phpinfo.php

Insert into the file:

(save CTRL+0, ENTER, CTRL+X)

open webbrowser on PC and try (page shows infos on php)

connect phpMyAdmin with MySQL database nano /etc/apache2/apache2.conf
- CTRL+V... to the end of the file
- Insert at the end of the file:  (save CTRL+0, ENTER, CTRL+X)Include /etc/phpmyadmin/apache.conf

restart apache/etc/init.d/apache2 restart
sudo apt-get update
sudo apt-get upgrade
sudo reboot



open webbrowser on PC and try #^


Create an empty database... that is later used by RED

open webbrowser on PC and try #^

Create an empty database

Note the access details (hostname, username, password, database name).

3. Selfhost

(Source: #^

Step 1
Register for a Free domain at #^
(We will take in this guide)

Step 2

Logon to FreeDNS (where you just registered) and goto #^
Right click on "Direct Link" and copy the URL and paste it somewhere.
You should notice a large and unique alpha-numeric key in the URL, make a note of it as shown below:

Step 3
Install inadyn using the following command:sudo apt-get install inadyn

Step 4
Configure inadyn using the below steps:sudo nano /etc/inadyn.conf
And add the following contains in it replacing the actual values:

--username techhome
--password mypassword
--update_period 3600
--forced_update_period 14400
--alias</b>,[color=red]alphanumeric key

Step 5

Now, we need to ensure that the DNS updater (Inadyn) runs automatically after every re-bootexport EDITOR=gedit && sudo crontab -e
Add the following line:@reboot /usr/sbin/inadyn

Step 6

Reboot system and then run the following command to ensure inadyn is running:
sudo reboot
ps -A | grep inadyn

Now your host is ready and up for accessing from internet...
You can trying ssh-ing from another computer over the internet
Or, if any web server is running, then simply browse to  #^
Or, you can just ping it to test ping
To check the logs you can use this:
more /var/log/messages |grep INADYN

4. Install Redmatrix


Linux Appache document root is /var/www/
Two files exist there (created by the steps above): index.html, phpinfo.php

Install Redmatrix and its Addons

Cleanup: Remove the directory www/ (Git will not create files and folders in directories that are not empty.) Make sure you are in directory varpi@pi /var $ cd /var

Remove directorypi@pi /var $ sudo rm -rf www/

Download the sources of Redmatrix from GIT
pi@pi /var $ sudo git clone www

Download the sources of the addons from GIT
pi@pi /var/www $ sudo git clone addon

Make user www-data the owner of the whole web directory (including subdirectories and files)
(TODO: This step has to be proofed by the next installation.)
pi@pi /var $ chown -R www-data:www-data /var/www/

Check if you can update the sources from git
pi@pi /var $ cd www
pi@pi /var/www $ git pull

Check if you can update the addons
pi@pi /var/www $ cd addon/
pi@pi /var/www/addon $ sudo git pull

Make sure folder store/[data]/smarty3 exists and is writable by the webserver
pi@pi /var/www $ sudo chmod ou+w "store/\[data\]/smarty3"

Create .htconfig.php and is writable by the webserver
pi@pi /var/www $ sudo touch .htconfig.php
pi@pi /var/www $ sudo chmod ou+w .htconfig.php

First start and initial configuration of your RED Matrix hub

In browser open #^
(Replace by your domain, see chapter selfhost. Be patient. It takes time.)

There might be errors like the following.

Error: libCURL PHP module required but not installed.
apt-get install php5-curl

Error: Apache webserver mod-rewrite module is required but not installed.
The default installation of Apache2 comes with mod_rewrite installed. To check whether this is the case, verify the existence of /etc/apache2/mods-available/rewrite.load
- pi@pi /var/www $ nano /etc/apache2/mods-available/rewrite.load
(You should find the contendt: LoadModule rewrite_module /usr/lib/apache2/modules/
To enable and load mod_rewrite, do the rest of steps.
Create a symbolic link in /etc/apache2/mods-enabled
- pi@pi /var/www $ sudo a2enmod rewrite
Then open up the following file, and replace every occurrence of "AllowOverride None" with "AllowOverride all".
- pi@pi /var/www $ sudo nano /etc/apache2/sites-available/default
Finally, restart Apache2.
- pi@pi /var/www $ sudo service apache2 restart

Error store is writable (not checked)
(TODO: Make writeable to group www-data only?)
pi@pi /var/www $ sudo mkdir store
pi@pi /var/www $ chown -R www-data:www-data /var/www/red/
pi@pi /var/www $ sudo chmod ou+w view


Set up a cron job to run the poller once every 15 minutes in order to perform background processing.
- pi@pi /var/www $ which php
Make sure you are in the document root directory of the webserver
- pi@pi /var/www $ cd /var/www/
Try to execute the poller in order to make sure it works
- pi@pi /var/www $ /usr/bin/php include/poller.php
Create the cronjob
- pi@pi /var/www $ crontab -e
- */15 * * * * cd /var/www/; /usr/bin/php include/poller.php
- Save and exit.

Prevent search engines from indexing your search pages. Why?  This can cause heavy resource use.

php util/config system block_public_search 1

5. Keep your Raspberry Pi and your Redmatrix up-to-date

Git update every day at 4 am and addons at 5 am every day
Try if the command is working
- pi@pi /var/www $ sudo git pull
Create the cronjob
- pi@pi /var/www $ crontab -e
Enter the following to update at 4:01 am every day
- 01 04 * * * cd /var/www/; sudo git pull
Enter the following to update the addons at 5:01 am every day
- 01 05 * * * cd /var/www/addon/; sudo git pull
Enter the following to update the Raspberry Pi (Raspbian OS = Debian) at 6:01 am every day
- 01 06 * * * sudo aptitude -y update && sudo aptitude -y safe-upgrade
Save and exit.

6. Running with SSL

Follow the instructions here:

Return to the Main documentation page