Debian架设h5ai文件服务器
4 3 月, 2017 | 添加评论
h5ai是一款不错的php目录列表程序,也就是php列目录工具,支持apache和nginx
介绍
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. Initially h5ai was an acronym for HTML5 Apache Index but now it supports other web servers too.
PS:Requires PHP 5.5+ and works fine with Apache httpd, lighttpd, nginx and Cherokee.
安装lnmp
screen -S lnmp
wget -c http://soft.vpser.net/lnmp/lnmp1.5.tar.gz -cO lnmp1.5.tar.gz && tar zxf lnmp1.5.tar.gz && cd lnmp1.5 && ./install.sh lnmp
lnmp vhost add
安装过程中可以先做好域名解析,上传ssl证书文件214035192850297.pem和214035192850297.key到/home/wwwroot下面,在安装ssl的时候用到上面的两个文件。
安装h5ai
cd /home/wwwroot/www.5752.me #www.5752.me换成你自己的目录
wget https://wget.5752.me/Computer/code/h5ai.tar.gz?hash=LxzB3r5D&download=1
tar zxvf h5ai.tar.gz
查看h5ai配置
打开https://YOUR-DOMAIN.TLD/h5ai/public/index.php
Private Cache directory这个是系统文件夹的权限,修改public和private文件夹里的cache文件夹就可以正常
chmod 666 private/cache
chmod 666 public/cache
Movie thumbs视频预览,执行:
apt-get install libav-tools
PDF thumbs预览,执行:
apt-get install aptitude
aptitude install imagemagick
Shell zip预览,执行:
apt-get install zip
Use EXIF thumbs预览,请参考https://www.vpser.net/manage/lnmp-php-install-ext.html中EXIF的安装方法
Shell tar,Shell zip和Shell du
vi /usr/local/php/etc/php.ini
找到如下一行
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
删除exec,passthru和scandir三个函数。
配置web服务器
将/h5ai/public/index.php添加到web服务器配置文件中默认首页文件列表代码的最后位置
Apache2
cd /etc/apache2/sites-available/
修改配置文件,增加一行
DirectoryIndex index.html index.php /h5ai/public/index.php
然后执行
a2enmod rewrite
最后
service apache2 reload
Nginx
修改如下conf文件
vi /usr/local/nginx/conf/vhost/www.5752.me.conf #www.5752.me.conf换成你自己的
把下面的内容
server
{
listen 80;
#listen [::]:80;
server_name wget.youhe.me n;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/wget.youhe.me;
include other.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}
换成
server {
listen 80;
server_name 5752.me www.5752.me; #换成你自己的域名
#HTTP重定向至HTTPS
rewrite ^/(.*) https://www.5752.me/$1 permanent; #换成你自己的域名
}
并把下面的
index index.html index.htm index.php default.html default.htm default.php;
换成
index index.html index.htm index.php default.html default.htm default.php /h5ai/public/index.php;
最后
/etc/init.d/nginx restart
修改/h5ai/private/conf/options.json优化程序
/*使用中科大Google Fonts镜像,提高国内加载速度*/
"resources": {
"scripts": [],
"styles": [
"//fonts.lug.ustc.edu.cn/css?family=Ubuntu:300,400,700%7CUbuntu+Mono:400,700"
]
},
/*启用下载功能,并以zip为下载多文件时的压缩格式*/
"download": {
"enabled": true,
"type": "shell-zip",
"packageName": null,
"alwaysVisible": false
},
/*允许显示文件信息及下载链接的二维码,但默认不显示,可在左侧栏开启*/
"info": {
"enabled": true,
"show": false,
"qrcode": true,
"qrFill": "#999",
"qrBack": "#fff"
},
/*以简体中文为默认语言*/
"l10n": {
"enabled": true,
"lang": "zh-cn",
"useBrowserLang": false
},
/*关闭视频及音频预览时的自动播放*/
"preview-aud": {
"enabled": true,
"autoplay": false,
"types": ["aud"]
},
"preview-vid": {
"enabled": true,
"autoplay": false,
"types": ["vid-avi", "vid-flv", "vid-mkv", "vid-mov", "vid-mp4", "vid-mpg", "vid-webm"]
},
/*不预览文本文件*/
"preview-txt": {
"enabled": true,
"styles": {
"txt": 1,
"txt-authors": 1,
"txt-c": 3,
"txt-cpp": 3,
"txt-css": 3,
"txt-diff": 1,
"txt-go": 3,
"txt-h": 3,
"txt-hpp": 3,
"txt-install": 1,
"txt-js": 3,
"txt-json": 3,
"txt-less": 3,
"txt-license": 1,
"txt-log": 1,
"txt-makefile": 1,
"txt-md": 2,
"txt-py": 3,
"txt-rb": 3,
"txt-readme": 1,
"txt-rtf": 1,
"txt-rust": 3,
"txt-script": 3,
"txt-xml": 1
}
},
/*启用搜索功能*/
"search": {
"enabled": true,
"advanced": true,
"debounceTime": 300,
"ignorecase": true
},
/*允许以复选框选择多个文件*/
"select": {
"enabled": true,
"clickndrag": false,
"checkboxes": true
},
/*允许使用树状目录,并默认启用*/
"tree": {
"enabled": true,
"show": true,
"maxSubfolders": 50,
"naturalSort": true,
"ignorecase": true
}
正常安装后,文件放置到和h5ai平级目录就可以,当然也可以建立文件夹等等..