Installation of LNMP Environment and Basic Configuration for h5ai Directory Indexing

Publish: 2017-11-02 | Modify: 2017-11-02

h5ai is an index directory program developed in PHP. Similar to Fdscript and PHP Directory Lister that have been introduced before, h5ai seems to have more features in terms of actual experience. Therefore, Xiaoz replaced the software library with h5ai and shared the configuration process.

Before starting, please make sure you have installed PHP environment. It is recommended to use OneinStack. If you are a beginner, you can install the Baota panel.

Download

# Execute in the root directory of the website
wget http://soft.xiaoz.org/website/h5ai-0.29.0.zip
unzip h5ai-0.29.0.zip

After downloading, unzip it to the root directory of the website, and the directory structure is as follows:

DOC_ROOT
 ├─ _h5ai
 ├─ your files
 └─ and folders

Nginx Configuration

Then access http://YOUR-DOMAIN.TLD/_h5ai/public/index.php to test if it can be opened. If everything is normal, you should see the following interface:

h5ai

If you have installed OneinStack, the configuration file is usually located at /usr/local/nginx/conf/vhost/domain.com.conf. Modify this configuration file and set /_h5ai/public/index.php as the default home page. The configuration is as follows:

index index.html index.htm index.php /_h5ai/public/index.php;

After modification, don't forget to reload Nginx (service nginx reload). If nothing goes wrong, you can see the effect by visiting your domain name again.

h5ai

Modify Default Language

h5ai supports multiple languages, but the default display is English. You can modify the configuration file _h5ai/private/conf/options.json:

"l10n": {
        "enabled": true,
        "lang": "en",
        "useBrowserLang": true
    },

Change "en" to "zh-cn", so that the default language will be Chinese.

"l10n": {
        "enabled": true,
        "lang": "zh-cn",
        "useBrowserLang": true
    },

Enable Search Function

Still, modify the options.json file. Change:

"search": {
        "enabled": false,
        "advanced": true,
        "debounceTime": 300,
        "ignorecase": true
    },

to

"search": {
        "enabled": true,
        "advanced": true,
        "debounceTime": 300,
        "ignorecase": true
    },

Display QR Code

For the convenience of downloading on some mobile software, you can enable the QR code display function, and directly scan and download with your mobile phone. Modify the options.json configuration file:

"info": {
        "enabled": false,
        "show": false,
        "qrcode": true,
        "qrFill": "#999",
        "qrBack": "#fff"
    },

Change "false" to "true":

"info": {
        "enabled": true,
        "show": true,
        "qrcode": true,
        "qrFill": "#999",
        "qrBack": "#fff"
    },

Replace Google Fonts

At this point, you will find that h5ai opens very slowly because it loads Google Fonts. However, Google Fonts are always unreliable in China, sometimes they can be accessed and sometimes they cannot. It is better to replace them. Modify the options.json configuration file and replace fonts.googleapis.com with fonts.lug.ustc.edu.cn. After replacement, it looks like this:

"resources": {
        "scripts": [],
        "styles": [
            "//fonts.lug.ustc.edu.cn/css?family=Ubuntu:300,400,700%7CUbuntu+Mono:400,700"
        ]
    },

Summary

h5ai is open source and provides more configuration options. It is feature-rich. After trying several index directory programs, h5ai is currently the most satisfactory one. Everyone can give it a try.


Comments