跳转到主要内容

安装

注意事项

  • 不再支持IIS部署
  • 不推荐使用Windows系统
  • 不再支持安装到二级目录

路径说明

假如您站点根目录为/www/wwwroot/xxx.com,您应该在此路径下创建一个zdir文件夹,并将zdir源码放到/www/wwwroot/xxx.com/zdir,需要读取的文件放到/www/wwwroot/xxx.com,结构如下:

/www/wwwroot/xxx.com/	- 站点根目录
	zdir		- zdir源码路径
	dir1		- 需要读取的文件夹
	file1		- 需要读取的文件

常规安装

  1. 访问 zdir.zip 下载最新源码,并解压到站点根目录

    下的zdir文件夹
  2. zdir/config.simple.php修改为zdir/config.php

  3. 修改config.php 文件,设置网站关键词、描述等、密码等

  4. 访问您的域名测试,文件管理用户名为zdir,密码为config.php中设置的密码

源码备用下载地址https://dwz.ovh/zdirdown

安装在子目录(推荐)

v1.50版本开始,Zdir支持安装在子目录运行,比如您的站点目录为/data/wwwroot/default,您可以将Zdir源码放在/data/wwwroot/default/zdir安装在子目录需要设置伪静态才能正常运行。

Nginx伪静态

  • 需要个将默认首页设置为zdir/index.php,比如index zdir/index.php index.html index.htm index.php
  • 需要在Server的配置中添加一行伪静态规则:rewrite ^/static/(.+) /zdir/static/$1 break;

下方是一个示例配置,请根据您的实际情况进行修改

server {
  listen 80;
  server_name localhost;
  #access_log /var/log/zdir.log combined;
  index zdir/index.php index.html index.htm index.php;
  root /data/wwwroot/default;

  #rewrite
  rewrite ^/static/(.+) /zdir/static/$1 break;
  #error_page 404 /404.html;
  #error_page 502 /502.html;

  location ~ [^/]\.php(/|$) {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi.conf;
  }

  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log off;
  }
  location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
  }
  location ~ /\.ht {
    deny all;
  }
}

Apache伪静态

Apache环境直接将/data/www/wwwroot/default/xxx.com/zdir/.htaccess.bak复制为/data/www/wwwroot/default/``xxx.com/.htaccess即可。或者自行在站点根目录下新建一个.htaccess文件,内容为:

RewriteEngine On
DirectoryIndex zdir/index.php
RewriteRule 'static/(.*)$' zdir/static/$1 [L] 

config.php设置

需要在config.php文件中将"thedir" => '',设置为您的站点根目录,比如:

"thedir"	=>	'/data/wwwroot/default',

注意:安装在子目录的方式,站点根目录不能以zdir命名,比如:**/web/zdir**是不允许的,应改为**/web/xxx**

Docker方式安装

Docker for Zdir一键部署脚本复制下面的命令执行

bashdocker <(curlrun -Lsk-name="zdir"  https:\
    -d -p 1080:80 --restart=always \
    -v /tmp/zdir:/raw.githubusercontent.com/helloxz/zdir/master/zdir-install.sh)data/wwwroot/default \
    helloz/zdir
  • 1080:为外部访问端口,可自行修改
  • /tmp/zdir:zdir数据挂载路径,可自行修改

更多说明请参考:https://www.xiaoz.me/archives/14809

config.php配置文件说明

设置站点基本信息

打开config.php 配置文件

$siteinfo = array(
		"site_name"	=>	"<i class='fa fa-sitemap' aria-hidden='true'></i> xiaoz软件库",
		"title"		=>	"Zdir 实用的目录列表程序",
		"keywords"	=>	"zdir,h5ai,Directory Lister,Fdscript,目录列表,目录索引",
		"description"	=>	"Zdir是一款使用PHP开发的目录列表程序,简单实用,免费开源。"
	);
  • site_name:网站名称(左上角显示)
  • title:设置站点标题(浏览器上显示)
  • keywords:设置网站关键词
  • description:设置网站描述

排除某个目录

//需要忽略的目录
	$ignore	= array(
		".",
		".git",
		"favicon.ico",
		"functions",
		"config.php",
		"index.php",
		"static",
		"LICENSE",
		"template",
		"cache.php",
		"indexes.php"
	);

如果您需要排除某个目录,请修改上面的$ignore变量。