搭建Apache2+h5ai实现美观的文件服务器

搭建Apache2+h5ai实现美观的文件服务器

h5ai是HTTP Web服务器的现代文件索引器。它使文件和目录以清楚优雅的方式显示,并且通过不同的视图来增强浏览的体验。
h5ai是HTML5 Apache Index的首字母缩写,但现在它也支持其他Web服务器。
我们经常利用apache来实现http访问服务器的文件,同时使用h5ai的话可以有更好的体验。

Requires PHP 5.5+ and works fine with Apache httpd, lighttpd, nginx and Cherokee.
Best user experience with the latest versions of Chrome, Firefox, Opera, Vivaldi, Safari and Edge,
but a static fallback is provided for older browsers or if JavaScript is disabled.

Features
There are lots of optional extensions and configuration options to customize the web appearance of your directory listings. All markup is valid HTML5 spiced up with CSS3 and finest JavaScript to build a fresh but minimal user interface and a user experience that focuses on your files.
Some of the optional features are:
sorting – view modes – localization – breadcrumb – tree view – custom headers+footers – filter+search – folder sizes – auto refresh – packaged download – QR codes – thumbnails – image+text+audio+video preview

参考链接
https://larsjung.de/h5ai/
https://blog.csdn.net/stay_zezo/article/details/80212552
https://blog.csdn.net/sdomain/article/details/6339270

安装apache2

sudo apt-get install apache2

配置文件
/etc/apache2/apache2.conf
主配置文件,inluce了其他配置文件

Apache2_conf.png

可添加下面的代码,实现相应功能

HeaderName /header.html
ReadmeName /footer.html
ServerSignature Off # 不显示apache版本号
IndexIgnore header.html footer.html # 忽略两个文件,不在文件列表里显示

-availablel文件夹和-enabled一一对应
前者存放着apache2可用的配置文件,后者则存放正在使用的配置文件的软链接

/etc/apache2/sites-available/
000-default.conf文件是使用http协议网站的默认网站配置文件,可以在此修改apache2的目录
default-ss.conf文件是https协议网站使用的默认网站配置文件

/etc/apache2/mods-available/dir.conf
在此修改apache2的主页

安装php7.0

sudo apt instal php7.0

安装模块使apache2支持php解析
sudo apt install php libapache2-mod-php

安装h5ai

下载h5ai
https://release.larsjung.de/h5ai/

将下载的压缩包解压,将_h5ai文件夹置于网站的根目录

DOC_ROOT
 └─ some
     └─ folder
         ├─ _h5ai
         ├─ your files
         └─ and folders
s

检查h5ai是否启用,访问
http://域名/_h5ai/public/index.php
目前密码为空,直接点login即可

修改密码前先生成密码的sha512值
https://md5hashing.net/hash/Sha512
将密码的Sha512值写在配置文件中
nano _h5ai/private/conf/options.json

配置h5ai为主页

Apache httpd 2.2/2.4:
DirectoryIndex index.html index.php /_h5ai/public/index.php

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

nginx 1.2:
index index.html index.php /_h5ai/public/index.php;

重新启动apache2即可生效
/etc/init.d/apache2 restart

# ,
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×