FileRun is a free, open-source, and self-hosted file-sharing application for Linux. It is a very good alternative to Google Drive and dropbox. It allows you to share and sync files, access via WebDAV and even connect to it with the Nextcloud mobile app. It is written in PHP and uses MariaDB as a database backend. It allows you to access your files anywhere via secure cloud storage, and also offers backup and sharing of your photos, videos, files, and more.

In this article, I will explain how to install FileRun with Apache and Let’s Encrypt SSL on Debian 11.

Prerequisites

  • A server running Debian 11.
  • A valid domain name pointed with your server IP.
  • A root password is configured on the server.

Install LAMP Server

First, you will need to install the Apache, MariaDB, PHP and other packages to your server. You can install all of them by running the following command:

apt-get install apache2 mariadb-server mariadb-client php libapache2-mod-php imagemagick ffmpeg php-imagick php-mysql php-fpm php-common php-gd php-json php-curl php-zip php-xml php-mbstring php-bz2 php-intl unzip -y

Once all the packages are installed, you will also need to install the IonCube loader to your system.

First, download the IonCube loader with the following command:

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

Once the download is completed, extract the downloaded file with the following command:

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

Next, create a ioncube configuration file and define the path of the IonCube source:

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

Add the following line:

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

Save and close the file then create a PHP configuration file for FileRun:

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

Add the following settings:

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 the Apache service to apply the changes:

systemctl reload apache2

Configure MariaDB Database

First, you will need to secure the MariaDB installation using the following command:

mysql_secure_installation

Answer all the questions as shown below:

Enter current password for root (enter for none):  PRESS ENTER
Set root password? [Y/n] Y 
New password:  
Re-enter new password:  
Remove anonymous users? [Y/n] Y 
Disallow root login remotely? [Y/n] Y 
Remove test database and access to it? [Y/n]  Y 
Reload privilege tables now? [Y/n] Y 

Next, log in to the MariaDB shell with the following command:

mysql -u root -p

Once you are log in, create a database and user with the following command:

MariaDB [(none)]> CREATE DATABASE filerun;

MariaDB [(none)]> CREATE USER 'filerun'@'localhost' IDENTIFIED BY 'password';

Next, grant all the privileges to the FileRun database with the following command:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON filerun.* TO 'filerun'@'localhost';

Next, flush the privileges and exit from the MariaDB with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;

MariaDB [(none)]> EXIT;

Once you are finished, you can proceed to the next step.

Download FileRun

First, download the latest version of FileRun with the following command:

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

Once the FileRun is downloaded, unzip the downloaded file using the following command:

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

Next, set proper permission and ownership with the following command:

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

chmod -R 755 /var/www/html/filerun

Once you are finished, you can proceed to the next step.

Configure Apache for FileRun

Next, you will need to create an Apache virtual host configuration file for FileRun. You can create it with the following command:

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

Add the following lines:

        ServerName filerun.example.com

        DocumentRoot /var/www/html/filerun

        
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        

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

Save and close the file then activate the Apache virtual host and rewrite module with the following command:

a2ensite filerun.conf

a2enmod rewrite

Next, restart the Apache service to apply the changes:

systemctl restart apache2

You can also check the Apache status with the following command:

systemctl status apache2

You should see the following output:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-01-29 15:14:56 UTC; 5s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 22533 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 22538 (apache2)
      Tasks: 6 (limit: 2341)
     Memory: 16.4M
        CPU: 94ms
     CGroup: /system.slice/apache2.service
             ??22538 /usr/sbin/apache2 -k start
             ??22539 /usr/sbin/apache2 -k start
             ??22540 /usr/sbin/apache2 -k start
             ??22541 /usr/sbin/apache2 -k start
             ??22542 /usr/sbin/apache2 -k start
             ??22543 /usr/sbin/apache2 -k start

Jan 29 15:14:56 debian11 systemd[1]: Starting The Apache HTTP Server...

Once you are finished, you can proceed to the next step.

Access FileRun Web UI

Now, open your web browser and access the FileRun web UI using the URL http://filerun.example.com. You will be redirected to the following page:

<img alt="FileRun Installation" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/02/echo/p1.png61fbcfcc148d3.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="403" loading="lazy" src="data:image/svg xml,” width=”750″>

Click on the Next button. you should see the server requirements check page:

<img alt="Install check" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/02/echo/p2.png61fbcfcc83d14.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="456" loading="lazy" src="data:image/svg xml,” width=”750″>

Click on the Next button. You should see the database setup page:

<img alt="Database setup" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/02/echo/p3.png61fbcfcd03a0c.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="460" loading="lazy" src="data:image/svg xml,” width=”750″>

Click on the Next button. Once the installation has been finished, you should see the following page:

<img alt="Installation finished" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/02/echo/p4.png61fbcfcd669fb.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="470" loading="lazy" src="data:image/svg xml,” width=”750″>

Click on the Next button. You should see the FileRun login page:

<img alt="Login to FileRun" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/02/echo/p5.png61fbcfcdd23fe.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="384" loading="lazy" src="data:image/svg xml,” width=”750″>

Provide your admin username, password, and click on the Sign in button. You should see the FileRun dashboard on the following page:

<img alt="FileRun dashboard" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/02/echo/p6.png61fbcfce4c995.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="389" loading="lazy" src="data:image/svg xml,” width=”750″>

Secure FileRun with Let’s Encrypt SSL

It is also recommended to secure your website with Let’s Encrypt SSL. First, you will need to install the Certbot client to install and manage the SSL. By default, the Certbot package is included in the Debian default repository so you can install it with the following command:

apt-get install python3-certbot-apache -y

Once the Certbot is installed, run the following command to secure your website with Let’s Encrypt SSL:

certbot --apache -d filerun.example.com

You will be asked to provide your email and accept the term of service as shown below:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for filerun.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/filerun-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/filerun-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/filerun-le-ssl.conf
Next, select whether or not to redirect HTTP traffic to HTTPS as shown below:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Type 2 and hit Enter to install the Let’s Encrypt SSL for your website:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/filerun.conf to ssl vhost in /etc/apache2/sites-available/filerun-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://filerun.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=filerun.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/filerun.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/filerun.example.com/privkey.pem
   Your cert will expire on 2022-4-29. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Conclusion

Congratulations! you have successfully installed FileRun with Apache and Let’s Encrypt SSL on Debian 11. You can now use FileRun to store your files, music, photos and share them with your friends and family.