_h5ai

H5ai是一款功能强大 php 文件目录列表程序,由德国开发者 Lars Jung 主导开发,它提供多种文件目录列表呈现方式,支持多种主流 Web 服务器,例如 NginxApacheCherokeeLighttpd 等,支持多国语言,可以使用本程序在线预览文本、图片、音频、视频等。

H5ai需要最低php5.5+

安装#

1. 搭建web环境#

可以用LNMP,LAMP,或者直接宝塔一类面板安装。

2. 下载并上传H5ai程序到根目录#

官网下载最新版本: https://release.larsjung.de/h5ai/

然后上传到网站根目录

目录关系

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

publicprivate权限777

3. 修改Nginx配置文件#

根据不同系统,修改当前域名下的Nginx配置文件
root一行把/_h5ai/public/index.php添加进去

Apache httpd 2.2 / 2.4:httpd.conf

Copy
DirectoryIndex index.html index.php /_h5ai/public/index.php

lighttpd 1.4:lighttpd.conf

Copy
index-file.names += ("index.html", "index.php", "/_h5ai/public/index.php")

nginx 1.2:nginx.conf

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

Cherokee 1.2: in cherokee.conf

Copy
vserver!1!directory_index = index.html,index.php,/_h5ai/public/index.php

最后重启Apache或者Nginx系统即可!

如宝塔面板,只需在网站-设置-配置文件中添加即可!

4. 修改PHP配置,解除禁用函数#

php配置文件路径:/usr/local/php/etc/php.ini

搜索:disable_functions找到下列内容

Copy
disable_functions=passthru,exec,system,chroot,scandir,...

删除scandirexecpassthru 保存

重启php : /etc/init.d/php-fpm restart

5. 检测H5ai系#

访问:http://YOUR-DOMAIN.TLD/_h5ai/public/index.php 检测H5ai系统兼容性

问题汇总#

删除根目录下面的默认index.html文件#

需要注意的是,在虚拟主机根目录下,如果有 index.html 的话(宝塔或者其他面板可能会放置一个默认的 index.html 文件),请将其删除,否则不显示虚拟主机下的任何目录及文件。

报错#

如果打开网页出现以下错误:Warning: putenv() has been disabled for security reasons in

原因:禁用了部分存在危险的PHP函数
解决方法:
php禁用函数删去putenv

修改网站配置#

根据个人需求,在/_h5ai/private/conf/options.json中修改配置

如设置默认语言为中文

Copy
"l10n": { //用户是否可以自行选择语言 "enabled": true, //默认语言,"zh-cn"为简体中文,其他支持的语言可以到"/_h5ai/conf/l10n"中查看 "lang": "zh-cn", //根据浏览器自动判断语言 "useBrowserLang": true },

开启搜索功能#

依然是修改options.json这个文件,将

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

false修改为true就OK了

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

显示二维码#

某些手机软件为了方便下载,可以开启二维码显示功能,直接用手机扫描下载,非常方便。修改options.json配置文件,

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

false修改为true就OK了

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

替换Google字体#

这时候你会发现h5ai打开速度非常缓慢,原因是加载了Google字体导致,Google字体在墙内总是时灵时不灵的一会儿打得开一会儿打不开,干脆替换掉。修改options.json配置文件将fonts.googleapis.com替换为fonts.lug.ustc.edu.cn即可,替换后如下:

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

总结#

h5ai是一款很不错的软件,可以实现很多功能,比如安装ffmpeg可以达到在线播放的功能。

安装过程也相对简单,只是不适合作为私人文件的存储,如果是私人网盘的话可以考虑KodCloud或者NextCloud。

参考#

  1. H5ai 完整安装及使用教程:https://www.tok9.com/amp/374
  2. 使用宝塔安装配置h5ai列目录程序:https://lala.im/3742.html
  3. h5ai服务器目录搭建详细教程以及各种坑的解说:https://www.laoliang.net/jsjh/technology/6930.html
posted @   王永杰的网络日志  阅读(344)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
点击右上角即可分享
微信分享提示
CONTENTS