云梦
www.htcp.net

h5ai 目录列表程序完整安装使用教程

什么是 h5ai

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

请注意,默认情况下,放到目录下的 .php 文件将会被直接执行,并不以文本显示。

安装

1.1 首先需要搭建好 Web 服务器,例如 LNMP(Linux/Nginx/MySQL/Php)组合,本文直接以 LNMP 组合为例。

推荐使用 PHP 7 版本。

1.2 下载 h5ai 安装包

转至官网下载:https://larsjung.de/h5ai/

1.3 设置好虚拟主机后,编辑虚拟主机配置文件:

vim /usr/local/nginx/conf/vhost/your_domain.conf

1.3.1 将 root 一行,改为:

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

1.4 去除被禁用的 PHP 函数:

vim /usr/local/php/etc/php.ini
搜索 scandirexecpassthru,将其从被禁用的函数中删除。

1.5 重启 web 服务器:

service php-fpm restart
service nginx reload

1.6 虚拟主机 ROOT 目录大概是这个样子的,要在网站上显示的目录和 _h5ai 文件夹放在一起:

.
├── _h5ai
│   ├── CHANGELOG.md
│   ├── private
│   ├── public
│   └── README.md
├── 您要显示的文件夹
│   ├── 子文件夹1
│   ├── 文件1
│   └── 文件2
└── 您要显示的文件夹
├── 文件1
└── 文件2

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

开启 h5ai 更多功能

到目前为止,h5ai 可以正常使用了,但是我们可以开启 _h5ai 全部功能。通过 http(s)://your_domain/_h5ai/public/index.php 可以查看 _h5ai 的全部功能开启情况,默认密码是空的。

2.1 安装 FFmpeg

debian 8:

2.1.1 编辑软件源文件:
vim /etc/apt/sources.list

2.1.2 添加四个软件源

deb http://www.deb-multimedia.org jessie main non-free
deb ftp://ftp.deb-multimedia.org jessie main non-free
deb http://www.deb-multimedia.org stable main non-free
deb ftp://ftp.deb-multimedia.org stable main non-free

2.1.3 更新软件源

apt-get -y update

2.1.4 安装 ffmpeg
apt-get -y install ffmpeg

Ubuntu 16.04+:

2.1.1 直接通过命令安装:

apt-get -y install ffmpeg

CentOS:

2.1.1 安装 FFmpeg 或 libav。

FFmpeg:

注意:请转至 http://www.ffmpeg.org/releases/ 查看最新的 FFmpeg 版本。

编译安装。

wget http://www.ffmpeg.org/releases/ffmpeg-*.*.tar.gz
tar -zxvf ffmpeg-*.*.tar.gz
cd ffmpeg-*.*
./configure
make
make install

libav:

http://libav.org/download/

下载源码编译即可。

2.2 略缩图功能

2.2.1 图片:
将 _h5ai 中,private 与 public 文件夹中的 cache 目录设置权限为 755。
2.2.2 EXIF:
通过 phpize 安装 PHP 的 exif 模块即可。
2.2.3 视频略缩图:
参考 2.1 安装 FFmpeg 即可。
2.2.3 PDF 略缩图:
安装 ImageMagick。

可使用如下命令:

Ubuntu/Debian:
apt-get install ImageMagick -y
CentOS:
yum install ImageMagick -y

2.3 Shell tar、Shell zip和Shell du

参考 1.4 去除在 php.ini 中被禁用函数 exec与 passthru 即可。

另外去除禁用的 scandir 函数(如果有),不然会导致无法显示目录。

2.4 options.json 中的更多功能

位于 _h5ai/private/conf 目录下。

打包下载:
搜索 “download”
127 行,enabled 由 false 改为 true。

文件信息及二维码:
搜索 “info”
185 行,enabled 由 false 改为 true。

默认简体中文:
搜索 “l10n”
202 行,enabled 由 false 改为 true。

文件及文件夹多选:
搜索 “select”
323 行,enabled 由 false 改为 true。

默认密码:

首先生成自定义 sha512 密码:http://md5hashing.net/hashing/sha512
然后搜索 “passhash”,大概第 10 行,将其密码改成自己生成的。

上一张完整开启所有功能的截图:

2.6 在目录头部或尾部显示 HTML 内容

在需要显示自定义 HTML 的目录下,添加 _h5ai.headers.html 和/或 _h5ai.footers.html。这个通常用于对该目录的一些说明。支持 HTML 标签。

_h5ai.headers.html 头部 HTML
_h5ai.footers.html 尾部 HTML

赞(6) 打赏
文章通过 CC 4.0 BY-NC-ND 协议发布,转载请注明出处:云梦 » h5ai 目录列表程序完整安装使用教程

评论 23

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #12

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package ImageMagick

    jxyk20076年前 (2018-11-07)回复
  2. #11

    请问手机无法播放怎么解决啊,而且电脑上播放mkv没有声音

    天气并未好转6年前 (2018-06-28)回复
  3. #10

    2.3 Shell tar、Shell zip和Shell du 这个怎么搞呢。。没明白哈。能否详细说一下。

    Mr.W6年前 (2018-05-07)回复
  4. #9

    你好,请问安装好了怎么使用,我可以打开/_h5ai/public/index.php,发现只有Use EXIF thumbs、Movie thumbs、PDF thumbs三个功能没有启用,但是我怎么访问我的文件系统?
    另外我使用yum安装的php,搜索系统后发现只有/etc/php.ini,但是这个文件里面也没有scandir这函数怎么办

    hhhh6年前 (2018-03-22)回复
    • Q1. 描述不清。请详细说明遇到的问题。
      Q2. 没有找到 scandir 就证明没有禁用该功能。

      晨晨6年前 (2018-03-22)回复
      • 我可以通过 http(s)://your_domain/_h5ai/public/index.php 查看 _h5ai 的全部功能开启情况。
        但是我直接访问http(s)://your_domain/就显示403,不是文件目录
        以下是我的nginx配置
        server {
        listen 8011;
        server_name localhost;
        location ~ \.php?.*$ {
        root /usr/local/nginx/html;
        index index.html index.php /_h5ai/public/index.php;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        autoindex on;
        }
        }

        hhhh6年前 (2018-03-22)回复
        • 如果要访问 http(s)://your_domain/ 的话,nginx listen 应该填 80 用于 http,443 用于 https。
          location 写的也不对,应该把
          root /usr/local/nginx/html;
          index index.html index.php /_h5ai/public/index.php;
          放到外面去。

          贴一份示例配置(https 的部分没写):
          server {
          listen 80;
          server_name domain.com;
          access_log dir_to/domain_access.log combined; # 访问日志
          index index.html index.htm index.php /_h5ai/public/index.php;
          root /somewhere/webhost_dir;
          location ~ [^/]\.php(/|$) {
          fastcgi_pass 127.0.0.1:9000;
          #fastcgi_pass unix:/dev/shm/php-cgi.sock; 使用 sock 方式可提高性能
          fastcgi_index index.php;
          include fastcgi.conf; # fastcgi 配置文件
          }
          }

          晨晨6年前 (2018-03-23)回复
          • 谢谢,原来是配置文件写错了。

            hhhh6年前 (2018-03-23)回复
  5. #8

    title里面的内容只是一闪而过,长期显示的却是网址,这个在哪里修改

    myitmx6年前 (2018-01-20)回复
  6. #7

    想知道在windows下如何配置,一个小白如此说到

    小白6年前 (2017-12-17)回复
  7. #6

    The following packages have unmet dependencies:
    ffmpeg : Depends: libavcodec57 (>= 10:3.3.5) but it is not going to be installed
    Depends: libavdevice57 (>= 10:3.3.5) but it is not going to be installed
    Depends: libavfilter6 (>= 10:3.3.5) but it is not going to be installed
    Depends: libavformat57 (>= 10:3.3.5) but it is not going to be installed
    Depends: libavresample3 (>= 10:3.3.5) but it is not going to be installed
    Depends: libavutil55 (>= 10:3.3.5) but it is not going to be installed
    Depends: libpostproc54 (>= 10:3.3.5) but it is not going to be installed
    Depends: libsdl2-2.0-0 (>= 2.0.4) but it is not going to be installed
    Depends: libswresample2 (>= 10:3.3.5) but it is not going to be installed
    Depends: libswscale4 (>= 10:3.3.5) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

    Chilsion6年前 (2017-12-06)回复
    • 你的软件源可能有问题。

      试试看:
      apt install -f

      sudo aptitude install ffmpeg

      晨晨6年前 (2017-12-06)回复
  8. #5

    博主:按照你2.1 debian 8:安装 FFmpeg的方法,在2.1.4输入apt-get -y install ffmpeg后出现:
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:
    字数超限,我把剩下的在留言给你。

    Chilsion6年前 (2017-12-06)回复
  9. #4

    你好。我更改了sha512 密码,但是只有访问./_h5ai/public/index.php的时候,也就是h5ai info page,才需要输入密码。那这个密码没什么用啊,毕竟没有什么信息。反而域名直接访问的文件目录才更需要密码。有办法可以做到访问域名时用密码登录吗?

    Chad7年前 (2017-11-01)回复
    • 既然需要用密码,那就使用网盘吧。

      晨晨7年前 (2017-11-01)回复
  10. #3

    如何让他像 h-t-tp//-firmware.koolshare.cn 一样打开文件夹先显示文本内容?

    无限啸傲7年前 (2017-09-14)回复
    • 加 _h5ai.headers.html。

      晨晨7年前 (2017-09-15)回复
  11. #2

    你好,你的文章我已转载自个人博客。https://www.itxdm.com

    底部已著名转自。我的网站每日流量为90PV左右,如果您需要删除可联系我。

    rabbit7年前 (2017-07-05)回复
  12. #1

    可以啊

    沉寂7年前 (2017-03-18)回复

如果您觉得文章有用,可以支持一下本站

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏