预览
我搭建的文件服务器
前提
- 系统Debian12
- 安装Caddy,可以参考反向代理Caddy安装教程
- 在FilesGallery官网下载index.php文件
安装php
因为官网提供的是php文件,所以我们还需要安装php让caddy支持php文件作为index页面。
安装PHP8.2
- Debian 12 的默认版本是 PHP 8.2。通过运行以下命令来安装它。
1root@elegant-bounty-1:~# sudo apt-get install php-fpm php-cli php-pgsql php-mbstring php-xml php-gd
- 检查安装的 PHP 版本
1root@elegant-bounty-1:~# php --version2PHP 8.2.28 (cli) (built: Mar 13 2025 18:21:38) (NTS)3Copyright (c) The PHP Group4Zend Engine v4.2.28, Copyright (c) Zend Technologies5 with Zend OPcache v8.2.28, Copyright (c), by Zend Technologies
- 配置PHP-FPM
1root@elegant-bounty-1:~# vi /etc/php/8.2/fpm/php.ini2
3# ...4upload_max_filesize = 50M5# ...6post_max_size = 50M7# ...8memory_limit = 256M
- 添加用户
这里需要添加一个用户,在caddy、sudo和php套接字组中,不然在后续的操作中,会遇到权限不足的问题,添加用户参考这里Debian11下创建用户和删除用户,在Debian12下同样适用。
假设我们这里添加的用户名称为cirry
。
- 修改套接字文件权限
1root@elegant-bounty-1:~# vi /etc/php/8.2/fpm/pool.d/www.conf2...3; Unix user/group of processes4; Note: The user is mandatory. If the group is not set, the default user's group5; will be used.6user = cirry7group = cirry8# ...9listen.owner = cirry10listen.group = cirry11listen.mode = 0660
- 将Caddy用户加入PHP-FPM组
1# 根据系统选择组名(Debian/Ubuntu用www-data,RHEL/CentOS用php-fpm)2sudo usermod -aG cirry caddy # Debian/Ubuntu
- 重启PHP-FPM和Caddy
1sudo systemctl restart php8.2-fpm2sudo systemctl restart caddy
- 检查Caddy
1journalctl -u caddy --since "5 minutes ago"
配置Caddy
1root@elegant-bounty-1:~# vi /etc/caddy/Caddyfile2
3# xxx.xxx.xxx 填写自己的域名4# /var/www/files 填写FilesGallery的index.php存放的位置5# unix//run/php/php8.2-fpm.sock 不同版本名称不同,debian12就填这个6
7xxx.xxx.xxx {8 root * /var/www/files9 file_server10 encode gzip11 php_fastcgi unix//run/php/php8.2-fpm.sock12}
填写完成后,保存重启caddy。
1root@elegant-bounty-1:~# systemctl restart caddy
查看网站
第一次打开网站,就会有个弹框提示
我是挺想支持的,但是这价格实在是太高了,单个网站39刀有点吃不消。
项目下载
项目安装完成后需要配置几个问题
- 解决官方文档的弹框问题
- 解决项目文件的远程加载卡顿问题
直接下载我提供的index.php和远程文件包就可以了,下载地址:FilesGallery-0.13.1
使用方式:
- 用我提供的index.php替代官方的index.php。
- 在
_files
下创建assets
文件夹,将解压下来的文件,全部放入这个文件夹中,参考文档Self-hosted assets。