之前用的网盘Nextcloud感觉太臃肿了,而且每次用Aria2下载完东西都需要进命令行敲occ扫描命令才能显示,感觉很是折腾,正好前段时间有人安利我Filerun这个网盘,高效美观,看了下确实不错,就折腾了下,但发现我的OL 3欧独服对国内的线路很差劲,上传同步非常卡,就索性拿了一台小鸡反代了一下,目感觉美滋滋~
多提一下,Filerun这是个闭源的商业网盘,免费个人版只有3个用户,官方网站显示你要是家庭用途可以申请更多用户,但要是商业用途还是建议使用付费版~~
老规矩,Debian10的操作系统,基于LNMP安装,使用Certbot的SSL牌照。
— LNMP环境搭建 —
常规的LNMP安装,不再赘述~
#安装nginx
apt -y install nginx
# ufw allow 'Nginx HTTP'
systemctl start nginx
systemctl enable nginx
# 安装MariaDB数据库
apt -y install mariadb-server
mysql_secure_installation
# 这里会提示你设置密码,重设完密码后最后四个问题选择YnYY
systemctl restart mariadb.service
systemctl enable mariadb.service
#安装PHP7.3
apt -y install php7.3 php7.3-common php7.3-cli php7.3-cgi php7.3-fpm php7.3-gd php7.3-mysql php7.3-sqlite3 php7.3-pgsql php7.3-opcache php7.3-mbstring php7.3-curl php7.3-xml php7.3-xmlrpc php7.3-zip php7.3-intl php7.3-json php7.3-bz2 php7.3-imagick php7.3-ldap
新建Filerun数据库
mysql -u root -p
#-------输入密码后执行数据库操作,记得修改密码---------
CREATE DATABASE filerun;
GRANT ALL ON filerun.* to 'filerun'@'localhost' IDENTIFIED BY 'Filerun数据库密码';
FLUSH PRIVILEGES;
exit
由于Filerun是闭源的,所以需要安装php的ioncube组件,如果你使用的是其他版本的php,请参考此处
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xvfz ioncube_loaders_lin_x86-64.tar.gz
cp ioncube/ioncube_loader_lin_7.3.so /usr/lib/php/20180731/
nano /etc/php/7.3/fpm/conf.d/00-ioncube.ini
#—————————将该文件修改如下————————---
zend_extension = "/usr/lib/php/20180731/ioncube_loader_lin_7.3.so"
#---------------------------------
为Filerun设置php配置文件,直接执行下面整段命令即可
cat >> /etc/php/7.3/fpm/conf.d/filerun.ini << EOF
expose_php = Off
error_reporting = E_ALL & ~E_NOTICE
display_errors = On
display_startup_errors = Off
log_errors = On
error_log = /var/log/php_errors.log
ignore_repeated_errors = Off
allow_url_fopen = On
allow_url_include = Off
variables_order = "GPCS"
allow_webdav_methods = On
memory_limit = 128M
max_execution_time = 300
output_buffering = Off
output_handler = ""
zlib.output_compression = Off
zlib.output_handler = ""
safe_mode = Off
register_globals = Off
magic_quotes_gpc = Off
file_uploads = On
upload_max_filesize = 1024M
post_max_size = 1024M
enable_dl = Off
disable_functions = ""
disable_classes = ""
session.save_handler = files
session.use_cookies = 1
session.use_only_cookies = 1
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_httponly = 1
session.save_path = "/var/lib/php/sessions"
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
date.timezone = "PRC"
EOF
修改完重启相关服务
systemctl restart nginx
systemctl restart php7.3-fpm.service
# 删除安装文件
rm ioncube_loaders_lin_x86-64.tar.gz
rm -rf ioncube/
— 配置Filerun站点 —
下载安装Filerun站点文件
mkdir -p /opt/wwwroot/filerun && cd /opt/wwwroot/filerun
wget -O FileRun.zip http://www.filerun.com/download-latest
unzip FileRun.zip
rm FileRun.zip
nano /etc/nginx/conf.d/filerun.conf
将配置文件修改如下:
server {
listen 80;
server_name 你的网盘域名;
return 301 https://你的网盘域名;
}
server {
listen 443 ssl http2;
root /opt/wwwroot/filerun/;
index index.php index.html index.htm;
server_name 你的网盘域名;
ssl on;
ssl_certificate /etc/letsencrypt/live/你的公钥路径/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/你的私钥路径/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
# individual nginx logs for this gitlab vhost
access_log /var/log/nginx/你的网盘域名.log;
error_log /var/log/nginx/你的网盘域名_error.log;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
# include the fastcgi_param setting
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
#Avoid sending the security headers twice
fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
}
client_max_body_size 1024m; #此处定义最大上传文件的大小,与php的配置相一致
location / {
client_max_body_size 1024m; #此处定义最大上传文件的大小,与php的配置相一致
}
}
测试重载,设置站点权限
nginx -t
systemctl reload nginx
chown -R www-data:www-data /opt/wwwroot/
chown -R 755 /opt/wwwroot/filerun
此时登录你的网站,便应该会进入Filerun安装页面,且配置测试应全部通过,你的网盘搭好了~
— 一些小调试 —
首先是设置网盘路径并修改权限,这一步的网盘路径/home/filerun可以随你喜好更改
mkdir /home/filerun && cd /home/filerun && chown -R www-data:www-data /home/filerun
安装一些扩展组件
apt install imagemagick php7.3-imagick pngquant ffmpeg -y
apt install libreoffice -y
为了网站安全,将前文中的Display_errors修改为OFF
# 直接执行下行条命令即可
sed -i 's/display_errors = On/display_errors = Off/' /etc/php/7.3/fpm/conf.d/filerun.ini
# 别忘了重启服务
systemctl restart php7.3-fpm.service
(可选:)修改Favicon 图标
nano /opt/wwwroot/filerun/customizables/config.php
#————————修改为下文----------
<?php
$config['app']['ui']['enable_favicon_ico'] = true;
搭配Aria2和AriaNG做离线下载,如果你参考的是本站的Aria2教程,那么只需修改配置文件中的下载位置即可
nano /etc/aria2/aria2.conf
# 修改对应的dir=/data/aria2/download为你设置的网盘路径
# 修改后如果Aria2无法启动多半是权限问题,请修改权限
当然Filerun还有其他很多有趣的玩法,就不一一介绍了,自己折腾去吧www
— 配置反向代理 —
这个就比较简单了,在你的任一台三网线路良好的vps上安装nginx,然后增添下文的站点配置即可
server {
listen 80;
server_name 你的反代域名;
rewrite ^(.*)$ https://你的反代域名$1 permanent;
}
server {
listen 443 ssl http2;
server_name 你的反代域名;
index index.html index.htm index.php default.html default.htm default.php;
ssl on;
ssl_certificate /etc/letsencrypt/live/你的公钥路径/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/你的私钥路径/privkey.pem;
ssl_session_timeout 10m;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_stapling on;
ssl_prefer_server_ciphers on;
gzip on;
gzip_proxied any;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/css appli$
gzip_disable “MSIE [1-6]\.”;
location / {
proxy_redirect off;
proxy_pass https://你的网盘域名;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
client_max_body_size 1024m;
}
}
测试无误重载Nginx后,打开你的反代网站,便大功告成~
求个宝塔安装方法,数据库出错了@(哈哈)
我不会用宝塔......,这里LNMP环境不太重要,你随便找个一键LNMP脚本也是一样的,或者告诉我是哪里出错了我看看