How to Install Friendica Social Network Platform on Ubuntu 20.04
This tutorial exists for these OS versions
- Ubuntu 22.04 (Jammy Jellyfish)
- Ubuntu 20.04 (Focal Fossa)
On this page
Friendica is a free, open-source and decentralized social networking platform that helps you to build and maintain your own social networking projects. It has built-in support for ActivityPub including, Mastodon, Hubzilla, OStatus, Pleroma and more. It allows you to import your websites and blogs into your social stream via RSS/Atom feeds. It provides a powerful user and admin dashboard that helps you to manage your social network from any device.
In this tutorial, we will show you how to install Friendica with Apache and Let's Encrypt SSL on Ubuntu 20.04.
Prerequisites
- A server running Ubuntu 20.04.
- A valid domain name pointed with your server IP.
- A root password is configured the server.
Getting Started
Before starting, you will need to update your system packages to the latest version. You can update them using the following command:
apt-get update -y
Once your server is updated, you can proceed to the next step.
Install LAMP Server
Friendica runs on webserver, written in PHP and uses MySQL as a database backend. So the LAMP stack must be installed in your system. If not installed, you can install it with the following command:
apt-get install apache2 mariadb-server php libapache2-mod-php php-common php-gmp php-curl php-intl php-mbstring php-xmlrpc php-mysql php-gd php-imagick php-xml php-cli php-zip php-sqlite3 curl git -y
Once all the packages are installed, edit the php.ini file and make some changes:
nano /etc/php/7.4/apache2/php.ini
Change the following lines:
memory_limit = 256M upload_max_filesize = 100M max_execution_time = 300 max_input_vars = 1500 date.timezone = Asia/Kolkata
Save and close the file when you are finished.
Create a Friendica Database
Next, you will need to create a database and user for Friendica. First, connect to the MySQL with the following command:
mysql
Once connected, create a database and user with the following command:
MariaDB [(none)]> CREATE DATABASE friendicadb;
MariaDB [(none)]> CREATE USER 'friendica'@'localhost' IDENTIFIED BY 'password';
Next, grant all the privileges to the Friendica database with the following command:
MariaDB [(none)]> GRANT ALL ON friendicadb.* TO 'friendica'@'localhost' WITH GRANT OPTION;
Next, flush the privileges and exit from the MySQL with the following command:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Once you are finished, you can proceed to the next step.
Download Friendica
Before downloading Friendica, you will need to install Composer in your system. You can install it with the following command:
apt-get install composer -y
Once installed, change the directory to Apache web root and download the latest version of Friendica from the Git repository:
cd /var/www/html
git clone https://github.com/friendica/friendica.git
Once the download is completed, change the directory to friendica and install the required PHP dependencies with the following command:
cd friendica
composer install --no-dev
Next, download the Friendica addons with the following command:
git clone https://github.com/friendica/friendica-addons.git
Next, set proper ownership and permission to the friendica directory:
chown -R www-data:www-data /var/www/html/friendica/
chmod -R 755 /var/www/html/friendica/
Once you are finished, you can proceed to the next step.
Configure Apache for Friendica
Next, you will need to create an Apache virtual host configuration file to host Friendica. You can create it with the following command:
nano /etc/apache2/sites-available/friendica.conf
Add the following lines:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/friendica ServerName friendica.example.com <Directory /var/www/html/friendica/> Options +FollowSymlinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Save and close the file then enable the Apache virtual host and rewrite module with the following command:
a2ensite friendica.conf
a2enmod rewrite
Next, reload the Apache service to apply the changes:
systemctl restart apache2
You can verify the status of the Apache service with the following command:
systemctl status apache2
You should get the following output:
? apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2021-02-07 09:20:58 UTC; 6s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 33243 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 33259 (apache2) Tasks: 6 (limit: 2353) Memory: 15.1M CGroup: /system.slice/apache2.service ??33259 /usr/sbin/apache2 -k start ??33260 /usr/sbin/apache2 -k start ??33261 /usr/sbin/apache2 -k start ??33262 /usr/sbin/apache2 -k start ??33263 /usr/sbin/apache2 -k start ??33264 /usr/sbin/apache2 -k start Feb 07 09:20:58 ubuntu2004 systemd[1]: Starting The Apache HTTP Server...
Access Friendica Dashboard
Now, open your web browser and access the Friendica web interface using the URL http://friendica.example.com. You will be redirected to the system check page:
Make sure all the PHP dependencies are installed then click on the Next button. You should see the following page:
Provide your domain name, installation path and click on the Submit button. You should see the following page:
Provide your database name, database username, password and click on the Submit. You should see the Site setting page:
Provide administrator email, language, time zone and click on the Submit button. Once the installation has been completed, you should see the following page:
Now, click on the registration page button and finish the registration process to access the Friendica.
Secure Friendica with Let's Encrypt SSL
It is always a good idea to secure your website with Let's Encrypt SSL. You will need to install the Certbot client to install and manage the SSL. You can install it with the following command:
apt-get install python3-certbot-apache -y
Once the Certbot is installed, run the following command to secure your website with Let's Encrypt SSL:
certbot --apache -d friendica.example.com
You will be asked to provide your email and accept the term of service as shown below:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator standalone, Installer None Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): [email protected] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Plugins selected: Authenticator apache, Installer apache Obtaining a new certificate Performing the following challenges: http-01 challenge for friendica.example.com Enabled Apache rewrite module Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/apache2/sites-available/friendica-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/apache2/sites-available/friendica-le-ssl.conf Enabling available site: /etc/apache2/sites-available/friendica-le-ssl.conf
Next, select whether or not to redirect HTTP traffic to HTTPS as shown below:
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Type 2 and hit Enter to install the Let's Encrypt SSL for your website:
Enabled Apache rewrite module Redirecting vhost in /etc/apache2/sites-enabled/friendica.conf to ssl vhost in /etc/apache2/sites-available/friendica-le-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://friendica.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=friendica.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/friendica.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/friendica.example.com/privkey.pem Your cert will expire on 2020-10-23. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
Now, you can access your website securely using the URL https://friendica.example.com.
Conclusion
Congratulations! you have successfully installed and configured Friendica social network platform on Ubuntu 20.04 server. You can now manage your social network community from the central location.