Nov 25, 2024 3 min read

FileRun: The Ultimate Guide to Self-Hosting

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

FileRun is a robust, self-hosted file management and sharing platform, often considered a lightweight alternative to Google Drive or Nextcloud. It provides full control over your data while offering advanced features like rich metadata handling, preview support for various media formats, and seamless integrations with third-party tools. In this guide, we’ll walk you through deploying FileRun, securing it with Nginx, enabling logs for debugging, setting up backups, updating the app, and unlocking its unique features.

Installing FileRun

πŸ“¦ Docker/Docker Compose Setup

Using Docker Compose is the simplest way to deploy FileRun. Below is a docker-compose.yml file tailored to FileRun's requirements:


version: '3.3'

services:

db:

image: mariadb:10.5

container_name: filerun_db

restart: unless-stopped

environment:

MYSQL_ROOT_PASSWORD: root_password

MYSQL_USER: filerun

MYSQL_PASSWORD: filerun_password

MYSQL_DATABASE: filerun

volumes:

- ./db_data:/var/lib/mysql

web:

image: filerun/filerun

container_name: filerun_app

restart: unless-stopped

ports:

- "8080:80"

environment:

FR_DB_HOST: db

FR_DB_PORT: 3306

FR_DB_NAME: filerun

MYSQL_USER: filerun

MYSQL_PASSWORD: filerun_password

volumes:

- ./filerun_data:/user-files

- ./filerun_config:/var/www/html

depends_on:

- db

To deploy FileRun:


mkdir filerun && cd filerun

nano docker-compose.yml  # Paste the above YAML

docker-compose up -d

This starts two containers: one for the MariaDB database and another for the FileRun application. Access FileRun at http://<server-ip>:8080.

πŸš€ Manual Installation

For those who prefer manual setup on a Linux server:

  1. Install Dependencies:

sudo apt update && sudo apt install -y apache2 php libapache2-mod-php mariadb-server unzip php-mysql

  1. Configure MariaDB:

sudo mysql

CREATE DATABASE filerun;

CREATE USER 'filerun'@'localhost' IDENTIFIED BY 'filerun_password';

GRANT ALL PRIVILEGES ON filerun.* TO 'filerun'@'localhost';

FLUSH PRIVILEGES;

EXIT;

  1. Download and Extract FileRun:

wget -O filerun.zip https://filerun.com/download-latest

sudo unzip filerun.zip -d /var/www/html/

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

  1. Enable Apache and Restart:

sudo a2enmod rewrite

sudo systemctl restart apache2

Access FileRun at http://<server-ip>/filerun to complete the installation.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

Using Nginx to route traffic to FileRun ensures better performance and flexibility. Below is a server block for your Nginx configuration:


server {

listen 80;

server_name example.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;

}

}

Save this file as /etc/nginx/sites-available/filerun and enable the configuration:


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

sudo nginx -t

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure the connection using Let’s Encrypt:


sudo apt install -y certbot python3-certbot-nginx

sudo certbot --nginx -d example.com

Let Certbot handle SSL renewals automatically.

πŸ› οΈ Testing and Reloading Nginx

Verify your Nginx configuration with:


sudo nginx -t

sudo systemctl reload nginx

Visit https://example.com to test your secure FileRun setup.

Logging and Debugging FileRun

πŸ—ƒοΈ Enabling Debug Logs

To enable debug-level logs, modify config.php in FileRun:


define('DEBUG', true);

πŸ“„ Viewing Logs

For Docker users:


docker logs filerun_app

For manual installations, check the logs at /var/www/html/filerun/logs/.

πŸ› οΈ Troubleshooting Common Issues

If you encounter a blank page, check PHP's error log:


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

πŸ“€ Exporting Logs

Send logs to an external ELK stack by mounting a shared volume to /var/www/html/filerun/logs/ in your Docker configuration.

Backup and Restore

πŸ—‚οΈ File-Based Backups

Backup FileRun’s data directory:


tar -czvf filerun_backup.tar.gz /user-files

πŸ”„ Database Backups

For Docker MariaDB:


docker exec filerun_db mysqldump -u filerun -pfilerun_password filerun > filerun_db_backup.sql

For manual MariaDB:


mysqldump -u filerun -pfilerun_password filerun > filerun_db_backup.sql

πŸ“… Automated Backup Scripts

Create a cron job to automate backups:


crontab -e

0 2 * * * /usr/bin/docker exec filerun_db mysqldump -u filerun -pfilerun_password filerun > /path/to/backups/filerun_db_backup.sql

Updating and Upgrading FileRun

⬆️ Updating Docker Images

Update FileRun’s Docker container with:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations, download the latest version and replace the existing files:


wget -O filerun.zip https://filerun.com/download-latest

sudo unzip -o filerun.zip -d /var/www/html/

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

πŸ” Checking for Updates

FileRun’s admin panel often notifies you of available updates. Alternatively, monitor their GitHub repo.

Leveraging FileRun’s Unique Features

πŸ”§ Enabling APIs

Activate FileRun’s API from the admin panel under Control Panel > API. Test the API with:


curl -X POST -H "Authorization: Bearer <token>" -d "param=value" https://example.com/api/path

🌟 Advanced Configurations

Enable external storage (e.g., Google Drive or S3) by navigating to Control Panel > External Storage and configuring credentials.

Wrapping Up

Self-hosting FileRun provides unparalleled control over your data while offering advanced file management features. Following this guide, you can deploy, secure, and manage FileRun effectively. Start exploring its powerful APIs, external storage options, and customization capabilities today!

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.