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 http://www.raspberrypi.org/downloads
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)

http://downloads.raspberrypi.org/noobs

unzip

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

(Source http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#)


More

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@192.168.178.37
sudo apt-get update
sudo apt-get dist-upgrade


(Source http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#)



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


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


Open webbrowser on PC and check http://192.168.178.37
Should show you a page like "It works"

(Source http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#)


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

(Source http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#)


Test installation

cd /var/www

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

Insert into the file:
<?php
  phpinfo();
?>

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

open webbrowser on PC and try http://192.168.178.37/phpinfo.php (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


(Source http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#)


phpMyAdmin

open webbrowser on PC and try #^http://192.168.178.37/phpmyadmin

(Source http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#)


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

open webbrowser on PC and try #^http://192.168.178.37/phpmyadmin

Create an empty database

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


3. Selfhost

(Source: #^http://www.techjawab.com/2013/06/setup-dynamic-dns-dyndns-for-free-on.html)

http://freedns.afraid.org/signup/

Step 1
Register for a Free domain at #^http://freedns.afraid.org/signup/
(We will take techhome.homenet.org in this guide)

Step 2

Logon to FreeDNS (where you just registered) and goto #^http://freedns.afraid.org/dynamic/
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:
http://freedns.afraid.org/dynamic/update.php?alphanumeric-key


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 techhome.homenet.org</b>,[color=red]alphanumeric key
--background
--dyndns_system default@freedns.afraid.org
--syslog



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
ssh username@techhome.homenet.org
Or, if any web server is running, then simply browse to  #^http://techhome.homenet.org
Or, you can just ping it to test ping techhome.homenet.org
To check the logs you can use this:
more /var/log/messages |grep INADYN


4. Install Redmatrix

(Source: http://redtest.dszdw.net/help/Install)

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 https://github.com/redmatrix/redmatrix.git www

Download the sources of the addons from GIT
pi@pi /var/www $ sudo git clone https://github.com/redmatrix/redmatrix-addons.git 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 #^http://einervonvielen.mooo.com/
(Replace einervonvielen.mooo.com by your domain, see chapter selfhost. Be patient. It takes time.)
(#^http://einervonvielen.mooo.com/index.php?q=setup)

There might be errors like the following.

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

Error: Apache webserver mod-rewrite module is required but not installed.
Solution
(Source: http://xmodulo.com/2013/01/how-to-enable-mod_rewrite-in-apache2-on-debian-ubuntu.html)
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/mod_rewrite.so)
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)
Solution:
(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

More

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
Enter
- */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:
https://github.com/friendica/friendica/wiki/Running-Friendica-with-SSL

Return to the Main documentation page