Setup h5ai with Nginx on Ubuntu server

Setup h5ai with Nginx on Ubuntu server

h5ai as a simple cloudstorage

h5ai is a modern file indexer for HTTP web servers with focus on your files. Directories are displayed in a appealing way and browsing them is enhanced by different views, a breadcrumb and a tree overview.

Once I have tried h5ai on Heroku, but this time I would like to use it as my file indexer on a “real” server together with Nginx reverse proxy.

Install PHP

h5ai requires PHP 5.5+. On Ubuntu, that’s simple:

sudo apt install php-fpm

Download h5ai

cd /var/www && mkdir h5ai && cd h5ai
wget https://release.larsjung.de/h5ai/h5ai-0.29.2.zip
unzip h5ai-0.29.2.zip && rm h5ai-0.29.2.zip

sudo permissions may required. wget & unzip commands only work if you have installed them through apt install ****.

Latest h5ai release could get from https://larsjung.de/h5ai/.

Nginx configuration

Now setup a new virtual host with Nginx.

sudo nano /etc/nginx/conf.d/h5ai.conf

Copy the following configuration:

server {
    listen 80;
    index index.php /_h5ai/public/index.php;
    server_name  h5ai.example.com; # change to your own domain
    
    root /var/www/h5ai;

    # individual nginx logs for this vhost
    access_log  /var/log/nginx/h5ai.example.com_access.log; # change to your own domain
    error_log   /var/log/nginx/h5ai.example.com_error.log;  # change to your own domain
        
    location /_h5ai/private {
        return 403;
    }

    location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }

    fastcgi_param HTTP_PROXY "";

    fastcgi_pass unix:/run/php/php7.1-fpm.sock;
    fastcgi_index index.php;

    include fastcgi_params;

    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    fastcgi_param  PATH_INFO         $fastcgi_path_info;
    }
}

Check the configuration with sudo nginx -t.

Change file permissions to the h5ai folder:

sudo chown -R www-data:www-data /var/www/h5ai

Reload Nginx to make the virtual host alive:

sudo systemctl reload nginx

Visit http://h5ai.example.com/_h5ai/public/index.php, to check if h5ai is reachable. This page shows some hints on the server’s capabilities.

h5ai configuration

The main configuration file is _h5ai/private/conf/options.json. You might want to change some of the documented settings. But there are some more files in _h5ai/private/conf you might have a look at.

THE END
Ads by Google

林宏

Frank Lin

Hey, there! This is Frank Lin (@flinhong), one of the 1.41 billion . This 'inDev. Journal' site holds the exploration of my quirky thoughts and random adventures through life. Hope you enjoy reading and perusing my posts.

YOU MAY ALSO LIKE

First taste of Heroku, h5ai for a file indexer

Tutorials

2017.04.20

First taste of Heroku, h5ai for a file indexer

I've known Heroku for a long time, but never have a try to build with it. This time, I found a beautiful file indexer, h5ai, that requires PHP 5.5+, and Heroku is a perfect platform to build and host it.

Setup an IKEv2 server with strongSwan

Tutorials

2020.01.09

Setup an IKEv2 server with strongSwan

IKEv2, or Internet Key Exchange v2, is a protocol that allows for direct IPSec tunnelling between networks. It is developed by Microsoft and Cisco (primarily) for mobile users, and introduced as an updated version of IKEv1 in 2005. The IKEv2 MOBIKE (Mobility and Multihoming) protocol allows the client to main secure connection despite network switches, such as when leaving a WiFi area for a mobile data area. IKEv2 works on most platforms, and natively supported on some platforms (OS X 10.11+, iOS 9.1+, and Windows 10) with no additional applications necessary.

TOC

Ads by Google