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

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

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.


Frank Lin

Hey, there! This is Frank Lin (@flinhong), one of the 1.4 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.


First taste of Heroku, h5ai for file indexer



First taste of Heroku, h5ai for 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.

Setting up snap Nextcloud on Ubuntu



Setting up snap Nextcloud on Ubuntu

Nextcloud, a fork of ownCloud, is a open-source file sharing server that allows you to store your personal content, like documents and pictures, in a centralized location, much like Dropbox. It also returns the control and security of your sensitive data back to you, thus eliminating the use of a third-party cloud hosting service. Here, I'm going to walk through the installing and configurations on Ubuntu 18.04 using the snappy packaging system.