How To Install FileRun on CentOS 8

In this tutorial, we will install a FileRun instance on a CentOS 8 server running Apache, MariaDB 10 and PHP 7.4 as FPM.

DigitalOcean users: Start by preparing a Centos 8 server with this tutorial.

Before you begin this tutorial you’ll need a CentOS 8 server.

This guide assumes that you have some experience with editing text files from the command line. We are using vim in our examples. Prior experience with installing and configuring Apache, MariaDB or PHP is however not necessary.

The following two commands will install, and start, the Apache web server:

sudo yum install httpd
sudo systemctl start httpd.service
sudo systemctl enable httpd.service 

You can verify that by visiting your server’s public IP address in your web browser. You should see the Apache welcoming page, letting you know that it is working properly.

Now that we have our web server up and running, it is time to install a database server. This server will be managing the FileRun database which holds the application settings, the users settings and information about your files.

With two simple commands the database server MariaDB will be installed and running:

sudo yum install mariadb-server
sudo systemctl start mariadb

Now that our MariaDB server is running, we want to run a simple script which will improve the security of our database:

sudo mysql_secure_installation

The prompt will ask you for your current MariaDB root password. Since you just installed MariaDB, you won’t have one, so leave it blank by pressing ENTER. Then the prompt will help you set a password:

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorization.

Set root password? [Y/n] y
New password: PASSWORD
Re-enter new password: PASSWORD
Password updated successfully!
Reloading privilege tables..
 ... Success!

For the rest of the questions, you should simply hit the ENTER key through each prompt to accept the default values. This will remove some sample users and databases, disable remote root logins, and load these new rules so that MariaDB immediately respects the changes we have made.

The last thing you will want to do is enable MariaDB to start on boot. Use the following command to do so:

sudo systemctl enable mariadb.service

The 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 MariaDB with the root account:

mysql -u root -p

Enter the password you set for the MariaDB 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 MariaDB user account that will interact with 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 MariaDB 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.

Given that CentOS 8 still provides by default the older PHP version 7.2 we first need to enable the newer yum module:

sudo yum module enable php:7.4

We can now install PHP 7.4:

sudo yum install php-fpm

Next, create the system startup links for PHP-FPM and start it:

sudo systemctl enable php-fpm.service
sudo systemctl start php-fpm.service

PHP-FPM is a daemon process (with the init script /etc/init.d/php-fpm) that runs a FastCGI server on port 9000.

To make Apache work with PHP-FPM we edit the Apache configuration file:

sudo vi /etc/httpd/conf/httpd.conf

and adding this somewhere near the end (before the IncludeOptional conf.d/*.conf line):

<Proxy "unix:/run/php-fpm/www.sock|fcgi://php-fpm">
     ProxySet disablereuse=off
</Proxy>
 
<FilesMatch \.php$>
     SetHandler proxy:fcgi://php-fpm
</FilesMatch>

Next, higher up in the same configuration file, locate the DirectoryIndex directive and append index.php:

DirectoryIndex index.html index.php

Restart Apache and now PHP is installed.

sudo systemctl restart httpd.service

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

sudo yum install php-mbstring php-opcache php-pdo php-mysqlnd php-gd php-xml php-zip php-json

One last module which is not included in the yum repository is ionCube. Download and extract the latest ionCube version using the following commands:

cd /usr/lib64/php/modules
sudo wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
sudo tar xvfz ioncube_loaders_lin_x86-64.tar.gz

Next, 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 vi /etc/php.d/01_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"

zend_extension = /usr/lib64/php/modules/ioncube/ioncube_loader_lin_7.4.so
Note: You can find the latest FileRun recommended PHP settings here: https://docs.filerun.com/php_configuration

Finally, we need to restart the PHP-FPM service for the changes to take effect:

sudo systemctl restart php-fpm.service

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

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

Place it in the root folder of your webserver (/var/www/html/).

And extract the files:

unzip FileRun.zip

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

sudo chown -R apache:apache system/data

If SElinux is installed and enabled, we need to change the context for Apache to be able to make changes inside that folder:

chcon -t httpd_sys_rw_content_t -R system/data

Now, open your web browser and point it to http://YOUR-SERVER-IP/

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:

  • 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 FileRun database connection setup

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

FileRun successfull installation FileRun successfull installation

Important: 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

Type in the previously copied credentials and hit Sign in.

Pointing a FileRun user account to an existing folder, you will most probably need to adjust the server’s SE context to allow access:

chcon -t httpd_sys_rw_content_t -R /your/folder

You might want to allow PHP to connect to external servers, for example to be able to update FileRun

setsebool -P httpd_can_network_connect on

and also allow Apache to be accessible through the firewall:

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd –reload

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.

Important: 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.

Next, connect to the MariaDB server again:

mysql -u root -p

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

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

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;

Install Certbot: https://certbot.eff.org/instructions?ws=apache&os=centosrhel8 Create an Apache virtual host: https://serverspace.io/support/help/apache-virtual-hosts-on-centos-8/ (You can point the virtual host to the same “/var/www/html”) Run the certbot:

certbot --apache

Add HTTP to HTTPS redirect via /var/www/html/.htaccess:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R,L]

You have now successfully deployed FileRun on a CentOS 8 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