Nov 14, 2024 3 min read

Hubzilla: The Ultimate Guide to Self-Hosting

Hubzilla: The Ultimate Guide to Self-Hosting
Table of Contents

Hubzilla is a powerful self-hosted platform designed for decentralized communication, content publishing, and social networking. It stands out for its rich feature set, including built-in federation with other platforms and advanced privacy controls. By hosting Hubzilla yourself, you gain full control over your data, extensive customization options, and the ability to connect seamlessly with other decentralized systems. This guide will walk you through the process of deploying, configuring, securing, and managing Hubzilla on your infrastructure.

Installing Hubzilla

πŸ“¦ Docker/Docker Compose Setup

To simplify deployment, we will use a docker-compose.yml file to run Hubzilla in Docker. This method ensures easy setup and portability.

Create a docker-compose.yml file:


version: '3.8'

services:

hubzilla:

image: hubzilla/hubzilla:latest

container_name: hubzilla

ports:

- "80:80"

- "443:443"

volumes:

- ./hubzilla_data:/var/www/html

- ./hubzilla_db:/var/lib/mysql

environment:

- MYSQL_ROOT_PASSWORD=securepassword

- MYSQL_DATABASE=hubzilla

- MYSQL_USER=hubzillauser

- MYSQL_PASSWORD=securepassword

restart: always

Deploy the application using Docker Compose:


docker-compose up -d

This will pull the latest Hubzilla image, set up a MySQL database, and start the application.

πŸš€ Manual Installation

If you'd like to deploy Hubzilla directly on a Linux server, follow these steps:

  1. Update your system and install dependencies:

sudo apt update && sudo apt upgrade -y

sudo apt install apache2 mariadb-server php php-mysql php-cli php-curl php-gd unzip wget -y

  1. Download and extract Hubzilla:

wget https://framagit.org/hubzilla/core/-/archive/master/core-master.zip

unzip core-master.zip

sudo mv core-master /var/www/html/hubzilla

sudo chown -R www-data:www-data /var/www/html/hubzilla

sudo chmod -R 755 /var/www/html/hubzilla

  1. Set up the database:

sudo mysql -u root -p

CREATE DATABASE hubzilla;

CREATE USER 'hubzillauser'@'localhost' IDENTIFIED BY 'securepassword';

GRANT ALL PRIVILEGES ON hubzilla.* TO 'hubzillauser'@'localhost';

FLUSH PRIVILEGES;

EXIT;

  1. Enable necessary Apache modules and restart:

sudo a2enmod rewrite

sudo systemctl restart apache2

Access Hubzilla in your browser at http://your-server-ip/hubzilla to complete the setup.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

If you're using Nginx as the web server or reverse proxy, create a new server block for Hubzilla:


server {

listen 80;

server_name your-domain.com;

root /var/www/html/hubzilla;

index index.php;

location / {

try_files $uri $uri/ /index.php?$args;

}

location ~ \.php$ {

include snippets/fastcgi-php.conf;

fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

location ~ /\.ht {

deny all;

}

}

Save the file as /etc/nginx/sites-available/hubzilla and enable it:


sudo ln -s /etc/nginx/sites-available/hubzilla /etc/nginx/sites-enabled/

sudo nginx -t

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure your setup with Let's Encrypt:


sudo apt install certbot python3-certbot-nginx -y

sudo certbot --nginx -d your-domain.com

Automate certificate renewals:


sudo crontab -e

0 3 * * * certbot renew --quiet && systemctl reload nginx

πŸ› οΈ Testing and Reloading Nginx

Verify the configuration:


sudo nginx -t

sudo systemctl reload nginx

Check the SSL status by accessing https://your-domain.com.

Logging and Debugging Hubzilla

πŸ—ƒοΈ Enabling Debug Logs

To enable debug-level logs in Hubzilla, edit the .htconfig.php file:


$a->config['system']['log_level'] = LOG_DEBUG;

πŸ“„ Viewing Logs

If using Docker:


docker logs hubzilla

For a manual install, check the Apache logs:


tail -f /var/log/apache2/error.log

πŸ› οΈ Troubleshooting Common Issues

Use the logs to diagnose issues like database connection errors or module failures. Common solutions include re-checking database credentials or ensuring PHP dependencies are installed.

πŸ“€ Exporting Logs

To forward logs to an external system like ELK Stack, configure a log shipper such as Filebeat to monitor Hubzilla’s log files.

Backup and Restore

πŸ—‚οΈ File-Based Backups

Backup your Hubzilla installation directory:


tar -cvzf hubzilla_backup.tar.gz /var/www/html/hubzilla

πŸ”„ Database Backups

Export the database:


mysqldump -u hubzillauser -p hubzilla > hubzilla_db_backup.sql

Restore the database:


mysql -u hubzillauser -p hubzilla < hubzilla_db_backup.sql

πŸ“… Automated Backup Scripts

Create a cron job to automate backups:


crontab -e

## Add the following line:

0 2 * * * tar -cvzf /backups/hubzilla_$(date +\%F).tar.gz /var/www/html/hubzilla && mysqldump -u hubzillauser -p'yourpassword' hubzilla > /backups/hubzilla_db_$(date +\%F).sql

Updating and Upgrading Hubzilla

⬆️ Updating Docker Images

To update Hubzilla in Docker:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations:


cd /var/www/html/hubzilla

git pull origin master

php util/udall

πŸ” Checking for Updates

Check Hubzilla’s admin panel or Git repository for announcements about new releases.

Leveraging Hubzilla’s Unique Features

πŸ”§ Enabling APIs

Activate the API in the admin settings. Test it with curl:


curl -X GET "https://your-domain.com/api/resource" -H "Authorization: Bearer your-api-token"

🌟 Advanced Configurations

Enable federation with other platforms:

  1. Go to the admin panel > Features.

  2. Enable the "Federation" module.

Integrate with third-party tools using WebDAV or CalDAV.

Wrapping Up

By following this guide, you’ve successfully deployed and configured Hubzilla, secured it with SSL, and set up logging and backups for long-term management. With its modular features and decentralized nature, Hubzilla empowers you to take full control of your digital presence. Start exploring its advanced features to unlock its full potential!

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.