How To Install FileRun on Ubuntu 16

In this tutorial, we will install a FileRun instance on an Ubuntu 16 server running Apache, MySQL and PHP 7. 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'll need an Ubuntu 16 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 16.04

Step 1 — Setting Up FileRun's Database

The MySQL database server is now configured and we can proceed with creating our FileRun database and the user account which will access it.

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

mysql -u root -p  

Enter the password you set for the MySQL root user when you installed the server.

FileRun requires a separate database for storing its data. While you can call this 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.

GRANT ALL ON filerun.* to 'filerun'@'localhost' IDENTIFIED BY 'YOUR-DB-PASSWORD';  

Note: Be sure to put an actual password where the command states: YOUR-DB-PASSWORD

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 MariaDB, 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  

One last module which needs manual install is ionCube.

Please follow this tutorial to get ionCube installed: How To Install ionCube on Ubuntu 16.04

With ionCube 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 nano /etc/php/7.0/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: http://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 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

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

FileRun server requirements check

Click Next to proceed with the database connection setup:

  • Type in the Database name you used at the step 2 of this tutorial: filerun
  • Type in the MySQL user: filerun
  • Type in the Password: set_database_password
  • Then click Next

FileRun database connection setup

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

FileRun successfull 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

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  

By default, the superuser's home folder is located inside /var/www/html/system/data/ folder. It is important that you edit the user account, from the FileRun control panel, and set the home folder path 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:

mysql -u root -p  

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

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

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 System configuration > Files > Image preview section, using the path /usr/bin/convert.

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 16.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 service apache2 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 nano /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 16 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 http://docs.filerun.com