Private Social Network with Raspberry Pi and OpenSource Social Network

4.3
(3)

Last Updated on 27th March 2022 by peppe8o

In this tutorial, I’m going to show you how to install OpenSource Social Network in a Raspberry PI.

Social networks spread everywhere, covering everyone’s life. But they are owned by companies, so you can be concerned about your privacy. With OpenSource Social Network (OSSN) you can create your own private one with a Raspberry PI and keep your data ownership.

Social Networks revolutionized people’s lives in the last few years. Everyone uses its social channels every day to stay connected with friends and family. But a common question regards the privacy and data security, which are shared with all world. Even if Social Networks created complex privacy policies to protect users, maintaining your data in your server is always the best option if you don’t want to make them available to the public.

Again, Raspberry PI with its Lite OS distribution can be very versatile to put in place a number of home useful services (see also my Raspberry Pi projects article). Some addicting features can be achieved by searching open source software and testing it with this fantastic device. An interesting example is installing OpenSource Social Network in your Raspberry PI.

For this project, I’m going to use a Raspberry PI 3 Model B, but this will work also on other Raspberry PI boards.

What Is OpenSource Social Network

OpenSource Social Network is “a rapid development social networking software written in PHP. It allows you to make a social networking website.
OSSN can be used to build different types of social apps.

  • Private Intranets
  • Public/Open Networks
  • Community

Supports:

  • Photos
  • Profile
  • Friends
  • Smileys
  • Search
  • Chat”

It runs on a LAMP server. Has very poor hardware requirements and an amazing user interface. Its interface is also mobile-friendly.

What We Need

As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if continue with the project or remove them from the shopping cart. So, hardware will be only:

Raspberry PI 3 Model B+ image

You will also need a Desktop PC with SFTP software (like, for example, the free Filezilla) to transfer installation packages into your RPI.

Check hardware prices with the following links:

Amazon raspberry pi boards box
Amazon Micro SD box
Amazon Raspberry PI Power Supply box

Step-By-Step procedure

We’ll start by setting up a classic LAMP server. We’ll then set up the database user and install OpenSource Social Network.

Prepare OS

Start from your operating system. I suggest to install Raspberry PI OS Lite (for a fast, headless environment), as done for this article. You can also use Raspberry PI OS Desktop, in this case using its internal terminal.

Make sure that your system is up to date. Connect via ssh terminal and type the following command:

sudo apt update -y && sudo apt upgrade -y

Install LAMP Server

LAMP (Linux – Apache – Mysql – Php) servers usually come with a MySQL database. In our project, we’ll use instead MariaDB because it is lighter and work fine with Raspberry Pi.

For the complete LAMP installation, please refer to my LAMP server on Raspberry PI tutorial.

Installing Other OpenSource Social Network Required Packages and Setting Up Php

We need to prepare our system for Open Source Social Network first setup wizard. Required packages are:

  • PHP version any of 5.6, 7.0, 7.1
  • MYSQL 5 OR >
  • APACHE
  • MOD_REWRITE
  • PHP Extensions cURL should be enabled
  • PHP GD Extension
  • PHP ZIP Extension
  • PHP settings allowurlfopen enabled
  • PHP JSON Support
  • PHP XML Support
  • PHP OpenSSL
  • PHP MBstring

So we’ll install them with the following terminal commands:

sudo apt install php-curl php-gd php-zip php-json php-xml php-mbstring -y

Enable MOD_REWRITE:

sudo a2enmod rewrite

Edit default Apache config to use mod_rewrite:

sudo nano /etc/apache2/sites-available/000-default.conf

Add the <Directory> section, so that your 000-default.conf file appears like the following (excluding comments):

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    # SECTION TO ADD --------------------------------
        <Directory /var/www/html>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
        </Directory>
    # END SECTION TO ADD --------------------------------
</VirtualHost>

allow_url_fopen should be already enabled in “/etc/php/7.4/apache2/php.ini”. OpenSSL should be already installed.

Another setting that I suggest is editing php max upload file size up to 16 MB:

sudo nano /etc/php/7.4/apache2/php.ini

Look for the row with upload_max_filesize parameter and set it as the following:

upload_max_filesize = 16M

Save and exit. Restart again Apache:

sudo systemctl restart apache2.service

Configure OSSN Database in MariaDB

Log into MariaDB shell as root:

sudo mariadb -u root

Create a database for OSSN (I called it “ossndb”, but you can name it as you prefer):

create database ossndb;

grant all privileges of OSSNdatabase to the user (with password) that you will configure in OSSN in the next steps. Please use your favourite database name, DB user and DB password instead of red ones (respectively ossndb, ossnuser and ossnpwd):

grant all privileges on ossndb.* to ossnuser@localhost identified by 'ossnpwd';

Flush the privileges table for the changes to take effect and then exit

flush privileges;
exit;
Install OSSN Software:

Get the link for OSSN zip file from OSSN download page: in the “basic version” area, right click with the mouse on “download OSSN” button and then select “Copy link address”. Then get the file directly in your Raspberry PI with the wget utility (the address link should be the same also for you):

wget https://www.opensource-socialnetwork.org/download_ossn/latest/build.zip

Now let’s extract the installation data directly in our

sudo unzip build.zip -d /var/www/html/ #Extracts from zip directly in Apache root folder
sudo rm /var/www/html/index.html #Removes Apache default page - we'll use OSSN one
sudo chown -R www-data:www-data /var/www/html/ #Grants apache permissions

OSSN requires a folder to store data. OSSN suggests, for security reasons, to create this folder outside of the published document root. So, we’ll create this in opt folder and give grants:

sudo mkdir /opt/ossn_data
sudo chown -R www-data:www-data /opt/ossn_data/

As the default installation files include a 1st level directory, in order to avoid the need to use “/ossn/” in your browser URL we can move all the installation files in Apache root and remove the /ossn/ folder:

sudo mv /var/www/html/ossn/{.*,*} /var/www/html/

This command will warn you wit the following message:

mv: cannot move '/var/www/html/ossn/.' to '/var/www/html/.': Device or resource busy
mv: cannot move '/var/www/html/ossn/..' to '/var/www/html/..': Device or resource busy

It is correct as it can’t move the parent folder, but this remains the most effective as it moves also the hidden files. We can also remove the ossn folder, now empty:

sudo rmdir /var/www/html/ossn/

Now, you can browse http://<<YourRpiIPAddress>> (mine one is 192.168.1.177) from a remote browser to start the installation wizard. The first stage validates that all the prerequisites are installed:

ossn installation validate

All checks should be fine. Please scroll down the page and click the “Next” button at the end. The next step proposes you the license:

ossn installation validate license

Read License validation and click the Next button (at the end of page) to accept. The next page requires setting up the database credentials (please use the ones created at the previous MariaDB configuration step)

ossn installation database configuration

Enter Database user, password, db name you chose. Remember also to insert OSSN data folder.

Finally press Install. The next page will allow you to create your Admin account:

ossn installation create admin

Then press Create button.

ossn installation complete

Everything should be fine now. Press Finish. You will be prompted for Admin credentials:

ossn login

Please fill the username and password set during the installation wizard to get the OSSN dashboard:

ossn admin dashboard

So, administration panel can be reached with URL “http://<<YourRpiIPAddress>>/administrator” while user link will be “http://<<YourRpiIPAddress>>”

ossn splash page

What’s Next

Interested in more cool ways to use your RPI? Take a look at peppe8o Raspberry PI computer tutorials!

Enjoy your OpenSource Social Network in your Raspberry PI!

How useful was this post?

Click on a star to rate it anonymously!

Average rating 4.3 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?