Table of Contents

How To Install FileRun on Ubuntu 20 with Apache

For an alternative using NGINX, use this tutorial.

In this tutorial, we will install a FileRun instance on an Ubuntu 20 server running Apache, MySQL and PHP. We will also configure the server with an SSL certificate and install any third-party software FileRun might make use of, so that you can enjoy all FileRun features on a secure server.

Prerequisites

Before you begin this tutorial you will need an Ubuntu 20 server, with Apache, MySQL and PHP.

Please follow this tutorial to set the prerequisites up: How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 20.04 You can stop before the step number 4 (Creating a Virtual Host for your Website) as the remaining steps are not required for the goal of this guide.

Step 1 — Setting Up FileRun’s Database

The MySQL server should be now ready for creating our FileRun database and the user account which will access it.

To get started, log into MySQL with the root account:

sudo mysql

While you can name your FileRun database whatever you prefer, we will be using the name filerun for this example.

)>
CREATE DATABASE filerun;

Next, create a separate MySQL user account that will manage the newly created database. Creating one-function databases and accounts is a good idea from a management and security standpoint. As with the naming of the database, choose a username that you prefer. We chose to go with the name filerun for this guide.

)>
CREATE USER 'filerun'@'localhost' IDENTIFIED BY 'YOUR-DB-PASSWORD';
Note: Be sure to put an actual password where the command states: YOUR-DB-PASSWORD

Now grant all privileges to the user on the newly created database:

)>
GRANT ALL ON filerun.* TO 'filerun'@'localhost';

With the user assigned access to the database, perform the flush-privileges operation to ensure that the running instance of MySQL knows about the recent privilege assignment:

)>
FLUSH PRIVILEGES;

This concludes the configuration of MySQL, therefore we will quit the session by typing:

)>
exit

Make a note of the database name filerun, the username filerun and the password YOUR-DB-PASSWORD as we will need this information again shortly.

Step 2 — Configuring PHP

The following command will install the PHP modules needed by FileRun:

sudo apt-get install php-mbstring php-zip php-curl php-gd php-ldap php-xml php-imagick php-mysql

One last module which needs manual install is ionCube:

Download the package (Linux 64 bit):

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

And extract it

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

Now, let’s load PHP with the downloaded extension:

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

And paste the following inside:

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

With the ionCube extension installed, let’s create a file which will automatically get appended by PHP to its configuration. This will include all the settings needed by FileRun.

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

Paste the following inside the created file:

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"
Note: You can find the latest FileRun recommended PHP settings here: https://docs.filerun.com/php_configuration

Finally, we need to restart Apache for the changes to take effect:

sudo systemctl restart apache2

Your server now meets all the requirements and we can proceed with installing FileRun.

Step 3 — Installing FileRun

Clean the default files from the root folder of your webserver (/var/www/html/):

cd /var/www/html/
sudo rm index.html
sudo rm info.php

Download FileRun:

Download the FileRun installation zip archive from the FileRun client account: https://filerun.com/client-area

Install unzip:

sudo apt-get install unzip

Extract the downloaded FileRun archive:

sudo unzip FileRun.zip

Make Apache the owner of the folder so that it can make change:

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

Open your browser and point it to http://YOUR-SERVER-IP

From here, you just have to follow the web installer, which will help you get FileRun running with just a few clicks.

From here you just have to follow the installer, which will help you get FileRun running with just a few clicks:

FileRun installer welcome screen FileRun installer welcome screen

Click Next to proceed. Review the server requirements check and make sure there is no red error message:

FileRun server requirements check FileRun server requirements check

Click Next to proceed with the database connection setup:

FileRun database connection setup FileRun database connection setup

You will be presented with the following screen, letting you know that FileRun has been successfully installed:

FileRun successful installation FileRun successful installation

Warning: Make sure you made a copy of the username and password displayed on the screen, before proceeding. The password is being randomly generated at this step. Do not use the password from this tutorial screenshot, it won’t work on your install.

Click Next to open FileRun. You should see the login page:

FileRun login page FileRun login page

The form should be prefilled so you can just hit Sign in.

Step 4 — Securing the FileRun installation

As soon as you sign into FileRun you will be prompted to change the password. Although the automatically generated password is quite secure, it’s still a good idea to set your own.

Warning: The FileRun superuser is the only account not protected against brute force login attacks, so it is very important that you set a password that cannot be guessed by a computer. Set a long password, containing also uppercase letters, digits and symbols.

Sign in as FileRun superuser, open the control panel and select the Software update option, click the Check for updates and install eventual available updates. This will make sure you are running the latest available FileRun version.

The permissions of the FileRun application files should not allow PHP (or any other web server application) to make changes to them:

sudo chown -R root:root /var/www/html

The system/data FileRun folder is the only folder where PHP needs write access.

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

Now let’s set the FileRun superuser’s home folder. It is important that the home folder path is pointing to a folder which is located outside the public area of your web server (ie. outside /var/www/html). You could create a folder /files and store all the FileRun files in there:

sudo mkdir /files
sudo chown www-data:www-data /files

Connect to the MySQL server as root again:

sudo mysql

Update the configured MySQL user account and remove the ALTER and DROP privileges.

)>
REVOKE ALTER, DROP ON filerun.* FROM 'filerun'@'localhost';
FLUSH PRIVILEGES;
exit

Note: You will need to add these permissions back before you will be installing any FileRun software update in the future. To do that, connect again to the database server and runt the following commands:

)>
GRANT  ALTER, DROP ON filerun.* TO 'filerun'@'localhost';
FLUSH PRIVILEGES;
exit;

Installing ImageMagick and FFmpeg

For generating thumbnails for image files, photography files and even PDF documents, install ImageMagick like this:

sudo apt-get install imagemagick

And enable it inside FileRun from the control panel, under the Configuration > Interface > Thumbnails and preview section, by setting ImageMagick support’s Mode to IMagick PHP Extension. Do press the Check version button to make sure FileRun can use the setting.

For generating thumbnails for video files install FFmpeg like this:

sudo apt-get install ffmpeg

And enable it inside FileRun from the control panel, under the System configuration > Files > Image preview section, using the path /usr/bin/ffmpeg.

Installing a SSL certificate with Let’s Encypt

This is highly recommended, to improve the security of your data and also to allow to access the FileRun API which the mobile apps use.

To proceed, please follow this tutorial: How To Secure Apache with Let’s Encrypt on Ubuntu 20.04

Additional Apache Configuration

Enabling mod_rewrite

mod_rewrite is an Apache module used for URL manipulations. FileRun needs this for certain features, such as opening an Microsoft Office file directly in your local program, without downloading it first.

sudo a2enmod rewrite

This will activate the module or alert you that the module is already in effect. To put these changes into effect, restart Apache:

sudo apachectl restart
Enabling .htaccess

A .htaccess file allows us to have custom configuration, defined per folder, without having to edit the Apache main configuration files.

By default, Apache prohibits using an .htaccess file, so first you need to allow changes to the file. Open the default Apache configuration file using nano or your favorite text editor.

sudo vim /etc/apache2/apache2.conf

Inside that file, you will find the block <Directory /var/www/>. Inside of that block, make sure AllowOverride is set to All.

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

Save and close the file. To put these changes into effect, restart Apache.

sudo systemctl restart apache2

Conclusion

You have now successfully deployed FileRun on a Ubuntu 20 server. It’s time to upload your files, photos, music or work documents and start sharing.

For more information on FileRun features and settings, visit https://docs.filerun.com