DEV Community

Cover image for Installing the fileserver 'filerun' on centos & nginx
Patrick Fehr
Patrick Fehr

Posted on

Installing the fileserver 'filerun' on centos & nginx

Hello community

This is my first post here and it expands on http://blog.filerun.com/how-to-install-filerun-on-centos-8/
Basically, the linked article guides you through installing the LAMP stack and FileRun with ionCube as a simple web-accessible fileserver for up- & downloading.

Story

As a home-server owner I just want to upload/download any type of files on my home server without depending on facebook, Amazon, Google, Microsoft or Plesk.

 Goals

  • Simple browser-accessible fileserver, localhosted (ok)
  • Low tech stack foot print (not ok)
  • nginx compatible, no apache (ok)
  • Simple IAM (ok)
  • Support for very large file uploads (not optimal)
  • Quick installation (ok)

Summary / key takeaways

  • Decided for https://filerun.com/
  • Battleground 1: Permissions (selinux)
  • Battleground 2: Installation pre-assumes "apache" as reverse proxy and clutters installation folders with it
  • Battleground 3: PHP7.4 is actually not supported by ionCube (a filerun dependency)
  • filerun on LAMP feels old & outdated, it feels like there should be newer alternatives 🤔

Disclaimer

These settings work for an unproxied centos8 instance for me. This should be more of a pitfalls warning/avoidance thread and not a copy/paste walkalong. I hope it's helpful, nevertheless.

Discovery

First I thought, I'd use some solution in combination with tus.io (resumable uploader) but I'd have to write it myself since there is nothing mature and/or open source out there. Maybe the usecase of uploading large files is less common than I thought - and massive POST requests are still state of the art(?).

So, I opened https://www.reddit.com/r/selfhosted and checked out some possibilities like:
https://seatable.io
https://nextcloud.com/
https://github.com/mickael-kerjean/filestash
I haven't checked airtable & matrify

As it appears, the listed solutions have a big tech stack footprint or only exist as docker image.
I like filestash but I have to still install a second local server (e.g. vsftp) and the IAM is not onboard.

Instructions

So I mostly followed http://blog.filerun.com/how-to-install-filerun-on-centos-8/
I skipped the apache installation & configuration and used my nginx config instead.
The php-remi repository steps and the mariadb installation were straight forward.

php-fpm installation:
I didn't touch the preinstalled php.ini since it appears to be better practice to create & edit a /etc/php.d/01-filerun.ini which gets invoked by php, anyway.

In /etc/php.d/01-filerun.ini I basically just increased the max-sizes/timeouts a bit and added the proper zend-extension line

memory_limit            = 50000M  
max_execution_time      = 10000
upload_max_filesize     = 50000M  
post_max_size           = 50000M  
zend_extension = /usr/lib64/php/modules/ioncube/ioncube_loader_lin_7.3.so

Then in /etc/php-fpm.d/www.conf the relevant configs - I listed the commented ones, too, because the acl entries would overwrite the owner/group lines if uncommented.

user = nginx
group = nginx
listen = /run/php-fpm/www.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
;listen.acl_users = apache,nginx
;listen.acl_groups =
listen.allowed_clients = 127.0.0.1

As of 07.06.2020 ioncube_loader_lin_7.4_10.4.0_beta2.so was working only in php -v but not on the php_info() page.
I only found through the ioncube loader-wizard.php that this meant I had to go uninstall php7.4 and go down to php7.3, great.

The following steps were required because php-fpm would write the apache group into these folders:

sudo chown -R root:nginx /var/lib/php /usr/lib64/php
sudo chown -R nginx:nginx /var/www /var/cache/nginx/cache

Also from within the documentation sudo chown -R apache:apache system/data should be replaced with your nginx user, e.g. nginx:nginx

 nginx configuration

General reminder: Check the nginx logs for errors, most often, the issue you'll have is because of (selinux) permissions or some nginx configuration issue.
Here are the relevant location blocks. I installed filerun in the folder /var/www/filerun.

user nginx;
log_format main '$document_root$fastcgi_script_name > $request'; # helps in finding fastcgi issues
access_log  /var/log/nginx/access.log  main;
error_log /var/log/nginx/error.log;

....

location /filerun {
    alias /var/www/filerun;
    index index.php;
    gzip on;
}

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    fastcgi_param HTTP_PROXY "";
    fastcgi_pass unix:/var/run/php-fpm/www.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

Debugging

Always test(!) - and if OK - restart the nginx server after a change

sudo nginx -t
sudo systemctl nginx restart
sudo tail -n 20 /var/log/nginx/error.log

php-fpm is not as chatty, but the service should at least report that it's up & running:

sudo tail -n 20 /var/log/php-fpm/error.log
sudo systemctl php-fpm restart 

Sidenotes

There is no php-imagemagick within centos8/remi anymore, instead use

sudo dnf install php-pecl-imagick

Top comments (5)

Collapse
 
mickaelkerjean profile image
Mickael

I like filestash but I have to still install a second local server (e.g. vsftp)

SSH servers comes with a builtin SFTP server you can use to connect directly.
In most cases, you don't have to install anything else.

Collapse
 
phuongdzu profile image
phuongdzu

Filestash is not open source.
With Docker you cannot edit anything. No value!

Collapse
 
mickaelkerjean profile image
Mickael

Filestash is released under AGPL, not part of it but all of it. Technically it's free software as per the gnu philosophy (gnu.org/philosophy/open-source-mis...)

Thread Thread
 
phuongdzu profile image
phuongdzu

Nextcloud is best choice, They have large community to support together

Collapse
 
burakisleyicii profile image
Burak İşleyici

You can also choose to use Localtonet File Server instead of all that hassle.