How to Install Friendica on Elementary OS

Friendica is a free, decentralized social networking platform that allows you to communicate with your friends without being dependent on any single company.

In this tutorial, we'll show you how to install Friendica on Elementary OS.

Prerequisites

Before we begin, make sure that you have the following:

Step 1: Install Nginx and PHP

Friendica requires a web server to run, so the first step is to install Nginx and PHP on your machine.

  1. Open Terminal and type the following command to update the package manager:
sudo apt update
  1. Once the update is finished, type the following command to install Nginx:
sudo apt install nginx
  1. After installing Nginx, we need to install PHP. Type the following command:
sudo apt-get install php7.4-fpm php7.4-curl php7.4-gd php7.4-intl php7.4-mbstring php7.4-mysql php7.4-xml
  1. Once the installation is finished, we need to restart the Nginx service by typing the following command:
sudo systemctl restart nginx

Step 2: Install MariaDB

Friendica requires MariaDB database to store the data. The following steps will guide you through the installation process.

  1. Type the following command in the Terminal to install MariaDB:
sudo apt-get install mariadb-server mariadb-client
  1. Once the installation is finished, start the MariaDB service:
sudo systemctl start mariadb
  1. After starting the service, we need to secure the database by typing the following command:
sudo mysql_secure_installation
  1. Follow the instructions given in the prompts to set up the root password, remove anonymous users, disable remote root login, and remove test databases.

Step 3: Create a database for Friendica

In this step, we will create a new database and user account for Friendica.

  1. Open the MySQL terminal by typing the following command:
sudo mysql -u root -p
  1. Enter the root password when prompted.

  2. Type the following command to create a new database:

CREATE DATABASE friendica_db;
  1. Create a new user account and grant all privileges to the database by using the following command:
GRANT ALL PRIVILEGES ON friendica_db.* TO 'friendica_user'@'localhost' IDENTIFIED BY 'password';

Note: Replace 'password' with a strong password.

  1. Exit the MySQL prompt by typing:
exit;

Step 4: Download Friendica

  1. Open your terminal and type the following command to navigate to the Nginx web root folder:
cd /var/www/html
  1. Download Friendica by typing the following command:
sudo git clone https://github.com/friendica/friendica.git
  1. Change the ownership of the Friendica folder to the Nginx user by using the following command:
sudo chown -R www-data:www-data friendica/

Step 5: Configure Nginx

In this step, you will create a new Nginx server block for Friendica.

  1. Type the following command to create a new server block config file:
sudo nano /etc/nginx/sites-available/friendica
  1. Paste the following configuration in the file:
server {
  listen 80;
  server_name yourdomain.com;
  
  root /var/www/html/friendica;
  index index.php index.html;
  
  access_log /var/log/nginx/friendica_access.log;
  error_log /var/log/nginx/friendica_error.log;
  
  # PHP-FPM Configuration
  location ~ \.php$ {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
      return 404;
    }
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
  }
  
  # Static files caching 
  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
  }
  
  # Rewrite URLs for Friendica
  location / {
    try_files $uri $uri/ /index.php?$args;
  }
}

Note: Replace 'yourdomain.com' with your own domain name.

  1. Save the changes and exit the text editor by pressing 'CTRL + X' and then typing 'Y' and 'Enter'.

  2. Type the following command to enable the friendica server block:

sudo ln -s /etc/nginx/sites-available/friendica /etc/nginx/sites-enabled/
  1. Test the configuration by typing the following command:
sudo nginx -t
  1. If there are no errors, restart the Nginx service:
sudo systemctl restart nginx

Step 6: Run the Friendica installer

  1. Open your web browser and go to http://yourdomain.com (replace 'yourdomain.com' with your own domain name).

  2. Follow the installation prompts by filling in the required details.

  3. When prompted for the database details, enter the following:

    • Database type: MariaDB/MySQL
    • Database host: localhost
    • Database name: friendica_db
    • Database user: friendica_user
    • Database password: (enter the password you created earlier)
  4. Continue with the installation and complete the setup.

Conclusion

Congratulations! You have successfully installed Friendica on Elementary OS. You can now start using Friendica to communicate with your friends and family in a decentralized way!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!