Some links in this post may be affiliate links. We may get paid if you buy something or take an action after clicking one of these, but without addictional costs for you compared to direct buying.

Private Social Network with Raspberry Pi and OpenSource Social Network

  • by
ossn_user_login_1

Before start reading: please consider, if this article is useful to you or if you just appreciate my work on it, to support me just sharing this article with your friends by your favourite Social Network. This would be a really appreciated help. Have a nice reading!

Social Networks revolutionized people life in last years. Everyone uses its social channels everyday to stay connected with friends and family. But a common question regards 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 public.

Again, Raspberry PI with Raspbian Lite version 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.

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

Raspberry PI 3 Model B+ image

This project is very simple and installing only web services from remote allows to need only a few cheap parts. I’m going to get it with a Raspberry Pi 3 model B+, but it should word also with Raspberry PI 3 model A+ or newer boards.

I suggest adding from now to your shopping chart all needed hardware, so that at the end you will be able to evaluate overall costs and decide if continuing with the project or removing them from shopping chart. So, hardware will be only:

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

Step-By-Step procedure

We’ll start from setting up a classic LAMP server. We’ll then setup database users and install OpenSource Social Network.

Install Raspbian Buster Lite OS

For this step you can simply follow my Install Raspbian Buster Lite in your Raspberry Pi article.

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

sudo apt-get update
sudo apt-get upgrade

Install LAMP Server

LAMP (Linux – Apache – Mysql – Php) servers usually comes with MySQL database. In our project we’ll use instead MariaDB because it is lighter and work fine with Raspberry Pi. I’ll go fast in this first part because installin a LAMP server is well documented over internet…

Install Apache Server:
sudo apt-get install apache2 -y

You should now be able to check that Apache installation has gone correctly by browsing http://<<YouRpiIPAddress>>:

Apache2 default page
Install PhP:
sudo apt-get install php -y
Install MariaDB Server and php connector:
sudo apt-get install mariadb-server php-mysql -y
Install PhpMyAdmin:

PhpMyAdmin is not mandatory in OpenSource Social Network, but I suggest to install because simplifies databases management.

sudo apt-get install phpmyadmin

In phpmyadmin setup screens I suggest the following:

  • select apache (mandatory) with space and press Ok
  • select Yes to configure database for phpmyadmin with dbconfig-common
  • insert your favourite phpmyadmin password and press Ok
  • insert again your phpmyadmin password to confirm and press Ok
Grant phpmyadmin user DB privileges to manage DBs:

We’ll connect to MariaDB with root user (defult password is empty) to grat permissions (remember to use semicolumns at the end of each command row as showed below):

sudo mysql -uroot -p
grant all privileges on *.* to 'phpmyadmin'@'localhost';
flush privileges;
quit

Finally restart Apache service:

sudo systemctl restart apache2.service

and check that phpmyadmin is working by browsing “http://<<YouRpiIPAddress>>/phpmyadmin/”

phpmyadmin default page

Default phpmyadmin login credentials are:

  • user: phpmyadmin
  • password: the one set up in phpmyadmin installation step

Installing Other OpenSource Social Network Required Packages and Setting Up Php

We need to prepare our system to OpenSource 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 & Mcrypt should be enabled
  • PHP GD Extension
  • PHP ZIP Extension
  • PHP settings allowurlfopen enabled
  • PHP JSON Support
  • PHP XML Support
  • PHP OpenSSL

So we’ll install them with following terminal commands:

sudo apt-get install php7.3-curl php7.3-gd php7.3-zip php7.3-json php7.3-xml

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>

Install Mcrypt:

sudo apt install php-dev libmcrypt-dev php-pear
sudo pecl channel-update pecl.php.net
sudo pecl install mcrypt-1.0.2

Enable Mcrypt module, by adding (or uncommenting) “extension=mcrypt.so” in “/etc/php/7.3/apache2/php.ini”:

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

allow_url_fopen should be already enablen in “/etc/php/7.3/apache2/php.ini”. Openssl should be already installed in php7.3.

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

sudo nano /etc/php/7.3/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

Install OSSN

Create DB And Setup User:

Go back to phpmyadmin web page (browse “http://<<YourRpiIPAddress>>/phpmyadmin/”) and login:

user: phpmyadmin

password: the one set up in phpmyadmin installation step

Click on Database Tab:

phpmyadmin database create 1

Create a database and take a note of the database name as you will require the same name in the further installation process.

ossn_phpmyadmin_setup_1

It’s time to create a database user for OSSN. In this example I’ll use the following credentials. Use the one at you choice, mostly for password:

user: ossn_db_user

password: ossn_db_password

So, terminal commands will be (root password is still empty, if not changed by you before):

sudo mysql -uroot -p
CREATE USER 'ossn_db_user'@'localhost' IDENTIFIED BY 'ossn_db_password';
GRANT ALL PRIVILEGES ON ossn_db.* TO 'ossn_db_user'@'localhost';
flush privileges;
quit
Install OSSN Software:

Download OSSN installation zip file from OSSN download page in your local PC. At the time of this article, this file is named “ossn-v5.2-1577836800.zip.

With you favoutire SFTP software transfer via SFTP the entire zip file to a new folder in path “/home/pi/download” in your Raspberry PI. Common (default) SFP connection parameters are:

  • host: your Raspberry Pi IP address
  • user: pi
  • password: raspberry (if you didn’t changed pi default password)
  • port: 22

Back to terminal:

cd /home/pi/download/ #Enter directory where OSSN installation files have been transferred
unzip ossn-v5.2-1577836800.zip #Extracts all files from zip
cd /var/www/html/ #Enter Apache web directory
sudo rm index.html #Removes Apache default page - we'll use OSSN one
sudo cp -R /home/pi/download/ossn-v5.2-1577836800/* ./ #Copy installation files to web directory
sudo chown -R www-data:www-data ./

Create Data Folder

OSSN requires a folder to store data. OSSN suggest, for security reason, to create this folder outside from 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/

Browse http://<<YourRpiIPAddress>> to start installation wizard:

ossn_setup_wizard_1

All checks should be fine. Please click Next button at the end of page.

ossn_setup_wizard_2

Read License validation and click Next button (at the end of page) to accept.

ossn_setup_wizard_3

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

ossn_setup_wizard_4

Enter your Admin account info. Press Create button.

ossn_setup_wizard_5

Everything should be fine now. Press Finish to access administration dashboard.

ossn_admin_login_2

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

ossn_user_login_1

Enjoy your OpenSource Social Network in Raspberry PI!

Leave a Reply

Your email address will not be published. Required fields are marked *