Friendica is a decentralized, federated social networking platform designed for self-hosting. It connects seamlessly with the Fediverse and supports interoperability with platforms like Mastodon, Diaspora, and more. Friendica empowers users by offering full control over their data, extensive customization options, and the ability to integrate with other social networks. In this guide, weβll walk through deploying, configuring, and managing Friendica, covering installation, reverse proxy setup, logging, backups, updates, and advanced features.
Installing Friendica
π¦ Docker/Docker Compose Setup
Using Docker Compose is one of the easiest ways to deploy Friendica. Below is a docker-compose.yml
file tailored for Friendica, complete with a MariaDB backend.
version: '3.7'
services:
db:
image: mariadb:10.5
container_name: friendica-db
restart: always
environment:
MYSQL_ROOT_PASSWORD: secret_root_password
MYSQL_DATABASE: friendica
MYSQL_USER: friendica_user
MYSQL_PASSWORD: secret_password
volumes:
- friendica_db_data:/var/lib/mysql
app:
image: friendica/friendica:stable
container_name: friendica-app
restart: always
environment:
DBTYPE: mysql
MYSQL_HOST: db
MYSQL_DATABASE: friendica
MYSQL_USER: friendica_user
MYSQL_PASSWORD: secret_password
ADMIN_MAIL: [email protected]
ADMIN_PASSWORD: admin_password
ports:
- "8080:80"
volumes:
- friendica_data:/var/www/html
depends_on:
- db
volumes:
friendica_data:
friendica_db_data:
Deploy Friendica using the following commands:
docker-compose up -d
This will start the Friendica app and its database on your server. Access it via your server's IP address or domain on port 8080.
π Manual Installation
For those who prefer direct control, here are the steps to manually install Friendica on a Linux server.
- Install required dependencies:
sudo apt update && sudo apt upgrade -y
sudo apt install -y apache2 mariadb-server php php-mysql php-gd php-xml php-mbstring git unzip
- Set up the database:
sudo mysql -u root -p
CREATE DATABASE friendica;
CREATE USER 'friendica_user'@'localhost' IDENTIFIED BY 'secret_password';
GRANT ALL PRIVILEGES ON friendica.* TO 'friendica_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
- Clone the Friendica repository and configure it:
cd /var/www
sudo git clone https://github.com/friendica/friendica.git friendica
sudo git clone https://github.com/friendica/friendica-addons.git friendica/addon
sudo chown -R www-data:www-data /var/www/friendica
sudo chmod -R 755 /var/www/friendica
- Configure Apache:
sudo nano /etc/apache2/sites-available/friendica.conf
Add the following:
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/friendica
<Directory /var/www/friendica>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/friendica_error.log
CustomLog ${APACHE_LOG_DIR}/friendica_access.log combined
</VirtualHost>
Enable the site and restart Apache:
sudo a2ensite friendica
sudo a2enmod rewrite
sudo systemctl restart apache2
Access your Friendica instance via the domain or IP you configured.
Configuring Nginx as a Reverse Proxy
π Nginx Configuration
Set up Nginx as a reverse proxy to route traffic to Friendica:
sudo nano /etc/nginx/sites-available/friendica
Add the following configuration:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Enable the configuration and reload Nginx:
sudo ln -s /etc/nginx/sites-available/friendica /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
π SSL/TLS Setup
Secure your Friendica instance with Let's Encrypt:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com
Set up automatic certificate renewal:
sudo crontab -e
Add the following:
0 0 * * * certbot renew --quiet
π οΈ Testing and Reloading Nginx
Validate the Nginx configuration and reload the service:
sudo nginx -t
sudo systemctl reload nginx
Logging and Debugging Friendica
ποΈ Enabling Debug Logs
To enable debug logging in Friendica, edit the config/local.config.php
file:
<?php
return [
'system' => [
'loglevel' => 4, // 4 is debug level
],
];
π Viewing Logs
If using Docker, check logs with:
docker logs friendica-app
For manual installations, view logs in Apache or Friendicaβs log directory:
tail -f /var/log/apache2/friendica_error.log
π οΈ Troubleshooting Common Issues
Check for database connection errors or misconfigured domains in the logs. Adjust environment variables or configuration files as needed.
π€ Exporting Logs
Forward logs to an ELK stack using filebeat
:
sudo apt install filebeat
sudo nano /etc/filebeat/filebeat.yml
Configure Friendica logs as an input, then restart filebeat
.
Backup and Restore
ποΈ File-Based Backups
Backup Friendicaβs files:
tar -czvf friendica_backup_$(date +%F).tar.gz /var/www/friendica
π Database Backups
Dump the database:
mysqldump -u friendica_user -p friendica > friendica_db_backup.sql
π Automated Backup Scripts
Add a cron job for automated backups:
crontab -e
Add:
0 2 * * * tar -czvf /path/to/backups/friendica_$(date +\%F).tar.gz /var/www/friendica
0 3 * * * mysqldump -u friendica_user -pYOURPASSWORD friendica > /path/to/backups/friendica_db_$(date +\%F).sql
Updating and Upgrading Friendica
β¬οΈ Updating Docker Images
Update the Friendica Docker image:
docker-compose pull
docker-compose up -d
π οΈ Manual Updates
For manual installations:
cd /var/www/friendica
sudo git pull origin stable
sudo chown -R www-data:www-data /var/www/friendica
π Checking for Updates
Visit the Friendica admin panel to check for available updates.
Leveraging Friendicaβs Unique Features
π§ Enabling APIs
Enable the Friendica API by adjusting the configuration:
<?php
return [
'system' => [
'api_enabled' => true,
],
];
You can now make API requests, such as fetching user posts:
curl -X GET -H "Authorization: Bearer <your-token>" https://yourdomain.com/api/statuses/user_timeline
π Advanced Configurations
Enable advanced federation settings by modifying config/local.config.php
:
<?php
return [
'system' => [
'diaspora' => true,
'gnusocial' => true,
],
];
Wrapping Up
This guide covered the essential steps to deploy, configure, and manage Friendica, including installation, reverse proxy setup, logging, backups, updates, and advanced features. By self-hosting Friendica, you gain unmatched control over your social networking experience while maintaining privacy and customization. Start implementing the provided examples today to unlock the full potential of Friendica!