For an alternative using Apache, use this tutorial.
In this tutorial, we will install a FileRun instance on an Ubuntu 20 server running NGINX, PHP and MariaDB. 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.
Before we install the LEMP stack, it’s a good practice to update repository and software packages by running the following commands on your Ubuntu 20 OS.
sudo apt update sudo apt upgrade
Nginx is a high-performance web server and very popular these days. It also can be used as a reverse proxy and caching server. Enter the following command to install Nginx Web server.
sudo apt install nginx
After it’s installed, we can enable Nginx to auto-start at boot time by running the following command.
sudo systemctl enable nginx
Then start Nginx with this command:
sudo systemctl start nginx
Opening the IP/hostname/domain of your server in the browser, should show the NGINX welcome page:
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 apt install mariadb-server mariadb-client
If it’s not running, start it with this command:
sudo systemctl start mariadb
To enable MariaDB to automatically start at boot time, run
sudo systemctl enable mariadb
Now run the post installation security script.
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 MariaDB 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.
Enter the following command to install PHP 7.4 and the extensions needed by FileRun.
sudo apt install php7.4 php7.4-fpm php7.4-mysql php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-mbstring php7.4-xml php7.4-zip php7.4-gd php7.4-curl php7.4-gd php7.4-ldap php7.4-imagick
One last PHP extension 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/fpm/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/fpm/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, let’s restart PHP-FPM:
sudo systemctl restart php7.4-fpm
Enable auto-start at boot time.
sudo systemctl enable php7.4-fpm
Check status:
systemctl status php7.4-fpm
The output will read active (running)
. If the above command doesn’t immediately quit after running. You need to press q
to make it quit.
Create an Nginx Server Block. An NGINX server block is like a virtual host in Apache. We will not use the default server block because it’s inadequate to run PHP code and if we modify it, it becomes a mess. So remove the default symlink in sites-enabled directory by running the following command. (It’s still available as /etc/nginx/sites-available/default.)
sudo rm /etc/nginx/sites-enabled/default
Then create a brand new server block file under /etc/nginx/conf.d/
directory.
sudo vim /etc/nginx/conf.d/default.conf
Paste the following inside:
server { listen 80; listen [::]:80; server_name _; root /var/www/html/; index index.php index.html; location / { try_files $uri $uri/ /index.php; } location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } include fastcgi_params; include snippets/fastcgi-php.conf; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass unix:/run/php/php7.4-fpm.sock; } # 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; } }
Then test the NGINX configuration:
sudo nginx -t
If the test is successful, reload NGINX:
sudo systemctl reload nginx
Your server now meets all the requirements and we can proceed with installing FileRun.
Clean the default files from the root folder of your webserver (/var/www/html/
):
cd /var/www/html/ sudo rm index.nginx-debian.html
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 the HTTP server 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:
Database name
you used at the step 2 of this tutorial: filerun
MySQL user
: filerun
Password
: YOUR-DB-PASSWORD
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 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
.
Read more about this here: https://docs.filerun.com/secure
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
Comming soon..
You have now successfully deployed FileRun on a Ubuntu 20 server with NGINX and PHP 7.4. 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