Install FileBrowser on Ubuntu

Install FileBrowser on Ubuntu

File Browser provides you with a file managing interface and it can be used to upload, delete, preview, rename and edit your files. It also allows the creation of multiple users, and each user can have its own directory.

I use it on some of my servers, such as Web or NGINX server; it is a simple way to be able to access files I need to either preview or update.

Although File Browser supports multiple platforms, in this article we concentrate on Ubuntu, getting it installed and running on Boot.

Install File Browser

Once connected to your server via SSH run “sudo -i”; otherwise, please add “sudo” before each of the commands in the instructions below.

To install File Browser, simply run the below command:

curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash

Run File Browser

To run it you would run a command as below:

filebrowser -p 8080 -a IP -r /path/to/your/folder

-p is the port it will listen on
-a is the IP address to listen on (your servers IP)
-r is the root directory that you’d like to access. On a web server that would often be “/var/www/html/”

Now test it, go to “http://yourServersIP:8080” and log in with the below:

Username: admin
Password: admin

And don’t forget to change your password.

You may notice that you cannot type any other commands o your SSH session; just push “CTRL + C” on your keyboard, unfortunately, this will also stop File Browser.

Continue reading so as to configure File Browser to run as a service.

Configure File Browser

Now we will configure File Browser so that we do not need to enter all the details at every start. To do that we will save all the configuration in a “.json” file, then call point to it when starting File Browser.

To start with, on your SSH client go to the path “/etc” (“cd /etc”).

Run “ls” and you should see a file named “filebrowser.db” amongst all the other files. Now we will create a new file, the “.json” configuration file, and add our configuration to it.

Start by running the command below;

nano filebrowser.json

This will open the nano editor, then paste the below into it, and edit “port”, “address” and “root” accordingly;

{
    "port": 8080,
    "baseURL": "",
    "address": "192.168.10.22",
    "log": "stdout",
    "database": "/etc/filebrowser.db",
    "root": "/var/www/html"
}

To save your file press “CRTL + O“; to close the editor press “CTRL + X“.

Now you only need to run the below command to start File Browser using the settings stored in the file above.

filebrowser -c /etc/filebrowser.json

Again, you cannot type any other commands o your SSH session; just push “CTRL + C” on your keyboard, unfortunately, this will also stop File Browser.

Follow the next steps to configure File Browser to run as a service.

Run File Browser on Startup/Boot

To start File browser as a service start y creating “filebrowser.service” in “/etc/systemd/system” by running the below;

nano /etc/systemd/system/filebrowser.service

Then paste into it the below;

[Unit]
Description=File Browser
After=network.target
[Service]
ExecStart=/usr/local/bin/filebrowser -c /etc/filebrowser.json
[Install]
WantedBy=multi-user.target

Now save your file press “CRTL + O“; to close the editor press “CTRL + X“.

Finally, run the below to enable this service to start at boot.

systemctl enable filebrowser.service

Before you reboot your machine, you can start and stop your File Browser service using the commands below for testing;

systemctl start filebrowser.service
systemctl stop filebrowser.service

And that is it, go ahead and reboot your machine; the service should start and be available once Ubuntu has booted.

If you need to access multiple directories, and not expose their root, then see this article.


Posted

in

by