How to Install FileRun on Ubuntu 20.04 with Apache/Nginx

fThis tutorial will be showing you how to install FileRun on Ubuntu 20.04 LTS with Apache/Nginx web server. FileRun is a self-hosted Google Drive/Photos/Music alternative.

FileRun Features

  • No index is required. It can access files on the file system directly.
  • Compatible with NextCloud.
  • Automatic file versioning.
  • 100% brandable. Upload your own logo.
  • Extendable. There are many plugins that allow you to create and edit office files, CAD files, etc.
  • Guest users.
  • Organize, Sync, and Share your Photos.
  • Built-in music player and organizer

Requirements

To follow this tutorial, you will need a domain name and a server. I registered my domain name at NameCheap because the price is low and they give whois privacy protection free for life. A server with 1G RAM is enough to run FileRun. Once you have a server, install Ubuntu on them and follow the instructions below.

FileRun is written in PHP and uses MySQL/MariaDB database. To follow this tutorial, it’s assumed that you have already set up LAMP or LEMP stack on Ubuntu 20.04. If not, please check out one of the following tutorials:

When you are finished setting up LAMP or LEMP stack, come back here and read on.

Step 1: Download FileRun on Ubuntu 20.04

Log in to your server via SSH. You can always use the following command to download the latest version of FileRun on your server.

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

Once downloaded, extract the archive with unzip.

sudo apt install unzip

sudo mkdir -p /var/www/filerun/

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

The -d option specifies the target directory. FileRun web files will be extracted to /var/www/filerun/. Then we need to change the owner of this directory to www-data so that the web server can write to this directory.

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

Step 2: Create a Database and User in MariaDB

Log into MariaDB database server with the following command.

sudo mysql

Alternatively, you can also use this command to login.

sudo mariadb

Then create a database for FileRun. This tutorial name the database filerun. You can use whatever name you like.

create database filerun;

Create the database user. Again, you can use your preferred name for this user. Replace your-password with your preferred password.

create user filerun@localhost identified by 'your-password';

Grant this user all privileges on the filerun database.

grant all privileges on filerun.* to filerun@localhost;

Flush privileges and exit.

flush privileges;

exit;

Step 3: Create Apache or Nginx Configuration File

Apache

If you prefer to use Apache web server, then create a virtual host configuration file in /etc/apache2/sites-available/ directory.

sudo nano /etc/apache2/sites-available/filerun.conf

Put the following text into the file. Replace filerun.example.com with your own domain name. Don’t forget to set A record for the domain name in your DNS manager.

<VirtualHost *:80>
        ServerName filerun.example.com

        DocumentRoot /var/www/filerun

        <Directory "/var/www/filerun">
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/filerun.error.log
        CustomLog ${APACHE_LOG_DIR}/filerun.access.log combined
</VirtualHost>

Save and close the file. Then enable the rewrite module.

sudo a2enmod rewrite

Then enable this virtual host.

sudo a2ensite filerun.conf

Restart Apache web server for the change to take effect.

sudo systemctl restart apache2

Nginx

If you prefer to use Nginx web server, then create a filerun.conf file in /etc/nginx/conf.d/ directory.

sudo nano /etc/nginx/conf.d/filerun.conf

Put the following text into the file. Replace filerun.example.com with your own domain name. Don’t forget to set A record for the domain name in your DNS manager.

server {
    listen [::]:80;
    listen 80;
    server_name filerun.example.com;

    access_log /var/log/nginx/filerun.access.log;
    error_log /var/log/nginx/filerun.error.log;
  
    root /var/www/filerun/;
    index index.php index.html;

   location / {
      try_files $uri $uri/ /index.php;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

    client_max_body_size 500M;

    location = /50x.html {
      root /usr/share/nginx/html;
    }

    location ~ \.php$ {
      fastcgi_pass unix:/run/php/php7.4-fpm.sock;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
      include snippets/fastcgi-php.conf;
    }

    #enable gzip compression
    gzip on;
    gzip_vary on;
    gzip_min_length 1000;
    gzip_comp_level 5;
    gzip_types application/json text/css application/x-javascript application/javascript image/svg+xml;
    gzip_proxied any;

    # A long browser cache lifetime can speed up repeat visits to your page
    location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
         access_log        off;
         log_not_found     off;
         expires           360d;
    }

    # disable access to hidden files
    location ~ /\.ht {
        access_log off;
        log_not_found off;
        deny all;
    }
}

Save and close the file. Test Nginx configuration, then reload Nginx for the changes to take effect.

sudo nginx -t

sudo systemctl reload nginx

Step 4: Install and Enable PHP Modules

Run the following commands to install PHP modules required or recommended by FileRun.

sudo apt install imagemagick ffmpeg php-imagick php7.4-mysql php7.4-fpm php7.4-common php7.4-gd php7.4-json php7.4-curl  php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl

Filerun uses ionCube to encrypt its PHP file, so we need to install the ionCube PHP loader to decrypt the PHP files. Dowload ionCube loaders.

wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

Extract it to /usr/lib/php/.

sudo tar -xzf ioncube_loaders_lin_x86-64.tar.gz -C /usr/lib/php

Now we need to enable the ioncube PHP extension.

Apache

If you use Apache, then create the PHP ini file for ionCube.

sudo nano /etc/php/7.4/apache2/conf.d/00-ioncube.ini

Add the following line to this file.

zend_extension = /usr/lib/php/ioncube/ioncube_loader_lin_7.4.so

Save and close the file. We need to create a second PHP ini file.

sudo nano /etc/php/7.4/apache2/conf.d/filerun.ini

Add the following lines. This is to change some of the default PHP configurations.

expose_php = Off
error_reporting = E_ALL & ~E_NOTICE
display_errors = Off
display_startup_errors = Off
log_errors = On
ignore_repeated_errors = Off
allow_url_fopen = On
allow_url_include = Off
variables_order = "GPCS"
allow_webdav_methods = On
memory_limit = 128M
max_execution_time = 300
output_buffering = Off
output_handler = ""
zlib.output_compression = Off
zlib.output_handler = ""
safe_mode = Off
register_globals = Off
magic_quotes_gpc = Off
upload_max_filesize = 20M
post_max_size = 20M
enable_dl = Off
disable_functions = ""
disable_classes = ""
session.save_handler = files
session.use_cookies = 1
session.use_only_cookies = 1
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_httponly = 1
date.timezone = "UTC"

Save and close the file. Reload Apache for the changes to take effect.

sudo systemctl reload apache2

Nginx

If you use Nginx, edit the php.ini file.

sudo nano /etc/php/7.4/fpm/php.ini

Add the following line right below the [PHP] line.

zend_extension=/usr/lib/php/ioncube/ioncube_loader_lin_7.4.so

Save and close the file. We need to create a second PHP ini file.

sudo nano /etc/php/7.4/fpm/conf.d/10-ioncube.ini

Add the following lines. This is to change some of the default PHP configurations.

expose_php = Off
error_reporting = E_ALL & ~E_NOTICE
display_errors = Off
display_startup_errors = Off
log_errors = On
ignore_repeated_errors = Off
allow_url_fopen = On
allow_url_include = Off
variables_order = "GPCS"
allow_webdav_methods = On
memory_limit = 128M
max_execution_time = 300
output_buffering = Off
output_handler = ""
zlib.output_compression = Off
zlib.output_handler = ""
safe_mode = Off
register_globals = Off
magic_quotes_gpc = Off
upload_max_filesize = 20M
post_max_size = 20M
enable_dl = Off
disable_functions = ""
disable_classes = ""
session.save_handler = files
session.use_cookies = 1
session.use_only_cookies = 1
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_httponly = 1
date.timezone = "UTC"

Save and close the file. Then restart Nginx and PHP7.4-FPM.

sudo systemctl restart nginx php7.4-fpm

Now you should be able to visit the FileRun web-based install wizard at http://filerun.example.com, but before entering any information, let’s enable HTTPS.

Step 5: Enable HTTPS

To encrypt the HTTP traffic when you visit the FileRun web interface, we can enable HTTPS by installing a free TLS certificate issued from Let’s Encrypt. Run the following commands to install Let’s Encrypt client (certbot) on Ubuntu 20.04.

sudo apt update
sudo apt install certbot

If you use Nginx, you also need to install the Certbot Nginx plugin.

sudo apt install python3-certbot-nginx

Then run the following command to obtain and install TLS certificate.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d filerun.example.com

If you use Apache, you also need to install the Certbot Apache plugin.

sudo apt install python3-certbot-apache

Then run this command to obtain and install TLS certificate.

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d filerun.example.com

Explanation:

  • --nginx: Use the nginx plugin.
  • --apache: Use the Apache plugin.
  • --agree-tos: Agree to terms of service.
  • --redirect: Force HTTPS by 301 redirect.
  • --hsts: Add the Strict-Transport-Security header to every HTTP response. Forcing browser to always use TLS for the domain. Defends against SSL/TLS Stripping.
  • --staple-ocsp: Enables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.

The certificate should now be obtained and automatically installed.

 

Step 6: Finish the Installation in your Web Browser

Go to https://filerun.example.com to launch the web-based install wizard. Then click Next button.

filerun install wizard

It will check if your system meets the requirements like PHP extensions. If all requirements are met, then click Next.

filerun server requirements

In the next step, enter the MariaDB username, password, and database name you created in step 2.

filerun database setup

After clicking Next, the install wizard will automatically create a user account. Click Next to continue.

filerun user account

On the next screen, you can log in with the superuser account. Upon first login, you need to create a home folder for the superuser account.

filerun superuser home folder

You can create the home folder for superuser with the following command.

sudo mkdir /var/www/superuser

sudo chown www-data /var/www/superuser/ -R

Then enter the folder path in FileRun web interface. And save the changes.

filerun folder permission

Next, go to Security -> API to enable the API, so client apps can sync with the server.

filerun enable api

Install FileRun Desktop Sync Client

On desktop, FileRun uses Nextcloud client to sync with the server.  On Ubuntu desktop, you can install Nextcloud client with:

sudo apt install nextcloud-desktop

For how to install client apps on other platforms, please check out the FileRun download page.

How to Set Up Email Notification

If there is more than one user, then it is a good idea to make FileRun be able to send email notifications like password reset emails. For how to set up an email server, please check out the following tutorial. Note that I highly recommend running iRedMail mail server on a fresh clean OS. Installing iRedMail on an OS that has other web applications can fail, and likely break existing applications.

If you don’t want to run your own email server, you can set up SMTP relay instead. Please see the following tutorial.

Wrapping Up

That’s it! I hope this tutorial helped you install FileRun on Ubuntu 20.04 server with Apache or Nginx. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 1 Average: 5]

3 Responses to “How to Install FileRun on Ubuntu 20.04 with Apache/Nginx

  • Hello, not work for me.

    I follow all your steps and appear this message:

    “Site error: the ionCube PHP Loader needs to be installed. This is a widely used PHP extension for running ionCube protected PHP code, website security and malware blocking. Please visit get-loader.ioncube.com for install assistance. ”

    U can help me?

    • Xiao Guoan (Admin)
      3 years ago

      Read step 4

      • Sorry for the confusion, I followed all your steps including step 4 and it still didn’t work, I finally realized that the IonCube package has to be based on your computer architecture, I was using a Raspberry Pi4 Model B and it didn’t work for me. with your link though, I went to the IonCube page and looked up my own for aarch64 and it finally worked!

        Linux ARM64 (aarch64 64 bits) -> https://www.ioncube.com/loaders.php

        It would be good to create a troubleshooting section with this that I have commented previously.

        Thank you very much for all your tutorials and guides, they are the most useful and easy to use. you’re great!

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here