本页内容
- 先决条件
- 安装 LAMP 服务器
- 配置 MariaDB 数据库
- 下载 FileRun
- 为 FileRun 配置 Apache
- 访问 FileRun Web 界面
- 使用 Let's Encrypt SSL 保护 FileRun
- 结论
FileRun 是一款面向 Linux 的免费、开源、可自托管的文件共享应用程序。它是 Google Drive 和 dropbox 的绝佳替代品。它允许你共享和同步文件、通过 WebDAV 访问,甚至可以使用 Nextcloud 移动应用连接它。它使用 PHP 编写,并使用 MariaDB 作为数据库后端。它允许你通过安全的云存储在任何地方访问你的文件,还提供照片、视频、文件等内容的备份与共享。
在本文中,我将介绍如何在 Debian 11 上使用 Apache 和 Let's Encrypt SSL 安装 FileRun。
先决条件
- 一台运行 Debian 11 的服务器。
- 一个指向你服务器 IP 的有效域名。
- 服务器上已配置 root 密码。
安装 LAMP 服务器
首先,你需要在服务器上安装 Apache、MariaDB、PHP 及其他软件包。你可以运行以下命令来安装所有这些软件包:
apt-get install apache2 mariadb-server mariadb-client php libapache2-mod-php imagemagick ffmpeg php-imagick php-mysql php-fpm php-common php-gd php-json php-curl php-zip php-xml php-mbstring php-bz2 php-intl unzip -y
所有软件包安装完成后,你还需要为系统安装 IonCube loader。
首先,使用以下命令下载 IonCube loader:
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
下载完成后,使用以下命令解压下载的文件:
tar -xzf ioncube_loaders_lin_x86-64.tar.gz -C /usr/lib/php
接下来,创建一个 ioncube 配置文件并定义 IonCube 源文件的路径:
nano /etc/php/7.4/apache2/conf.d/00-ioncube.ini
添加以下行:
zend_extension = /usr/lib/php/ioncube/ioncube_loader_lin_7.4.so
保存并关闭文件,然后为 FileRun 创建一个 PHP 配置文件:
nano /etc/php/7.4/apache2/conf.d/filerun.ini
添加以下设置:
expose_php = Off error_reporting = E_ALL & ~E_NOTICE display_errors = Off display_startup_errors = Off log_errors = On 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 upload_max_filesize = 20M post_max_size = 20M 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 date.timezone = "UTC"
保存并关闭文件,然后重启 Apache 服务以使更改生效:
systemctl reload apache2
配置 MariaDB 数据库
首先,你需要使用以下命令来加固 MariaDB 安装:
mysql_secure_installation
按如下所示回答所有问题:
Enter current password for root (enter for none): PRESS ENTER Set root password? [Y/n] Y New password: Re-enter new password: Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
接下来,使用以下命令登录 MariaDB shell:
mysql -u root -p
登录后,使用以下命令创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE filerun;
MariaDB [(none)]> CREATE USER 'filerun'@'localhost' IDENTIFIED BY 'password';
接下来,使用以下命令为 FileRun 数据库授予所有权限:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON filerun.* TO 'filerun'@'localhost';
接下来,使用以下命令刷新权限并退出 MariaDB:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
完成后,你可以继续下一步。
下载 FileRun
首先,使用以下命令下载最新版本的 FileRun:
wget -O FileRun.zip https://filerun.com/download-latest
FileRun 下载完成后,使用以下命令解压下载的文件:
unzip FileRun.zip -d /var/www/html/filerun/
接下来,使用以下命令设置适当的权限和所有权:
chown -R www-data:www-data /var/www/html/filerun
chmod -R 755 /var/www/html/filerun
完成后,你可以继续下一步。
为 FileRun 配置 Apache
接下来,你需要为 FileRun 创建一个 Apache 虚拟主机配置文件。你可以使用以下命令创建它:
nano /etc/apache2/sites-available/filerun.conf
添加以下行:
<VirtualHost *:80>
ServerName filerun.example.com
DocumentRoot /var/www/html/filerun
<Directory "/var/www/html/filerun">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/filerun.error.log
CustomLog ${APACHE_LOG_DIR}/filerun.access.log combined
</VirtualHost>
保存并关闭文件,然后使用以下命令启用 Apache 虚拟主机和 rewrite 模块:
a2ensite filerun.conf
a2enmod rewrite
接下来,重启 Apache 服务以使更改生效:
systemctl restart apache2
你也可以使用以下命令检查 Apache 状态:
systemctl status apache2
你应该会看到以下输出:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-01-29 15:14:56 UTC; 5s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 22533 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 22538 (apache2)
Tasks: 6 (limit: 2341)
Memory: 16.4M
CPU: 94ms
CGroup: /system.slice/apache2.service
??22538 /usr/sbin/apache2 -k start
??22539 /usr/sbin/apache2 -k start
??22540 /usr/sbin/apache2 -k start
??22541 /usr/sbin/apache2 -k start
??22542 /usr/sbin/apache2 -k start
??22543 /usr/sbin/apache2 -k start
Jan 29 15:14:56 debian11 systemd[1]: Starting The Apache HTTP Server...
完成后,你可以继续下一步。
访问 FileRun Web 界面
现在,打开你的 Web 浏览器,使用 URL http://filerun.example.com 访问 FileRun Web 界面。你将被重定向到以下页面:

点击 Next 按钮。你应该会看到服务器需求检查页面:

点击 Next 按钮。你应该会看到数据库设置页面:

点击 Next 按钮。安装完成后,你应该会看到以下页面:

点击 Next 按钮。你应该会看到 FileRun 登录页面:

输入你的管理员用户名、密码,然后点击 Sign in 按钮。你应该会在以下页面看到 FileRun 仪表板:

使用 Let's Encrypt SSL 保护 FileRun
还建议使用 Let's Encrypt SSL 保护你的网站。首先,你需要安装 Certbot 客户端来安装和管理 SSL。默认情况下,Certbot 软件包已包含在 Debian 默认仓库中,因此你可以使用以下命令安装它:
apt-get install python3-certbot-apache -y
Certbot 安装完成后,运行以下命令以使用 Let's Encrypt SSL 保护你的网站:
certbot --apache -d filerun.example.com
系统将要求你提供邮箱并接受服务条款,如下所示:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator standalone, Installer None Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): [email protected] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Plugins selected: Authenticator apache, Installer apache Obtaining a new certificate Performing the following challenges: http-01 challenge for filerun.example.com Enabled Apache rewrite module Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/apache2/sites-available/filerun-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/apache2/sites-available/filerun-le-ssl.conf Enabling available site: /etc/apache2/sites-available/filerun-le-ssl.conf Next, select whether or not to redirect HTTP traffic to HTTPS as shown below:
请选择是否将 HTTP 流量重定向到 HTTPS,从而移除 HTTP 访问。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
输入 2 并按 Enter 键,为你的网站安装 Let's Encrypt SSL:
Enabled Apache rewrite module Redirecting vhost in /etc/apache2/sites-enabled/filerun.conf to ssl vhost in /etc/apache2/sites-available/filerun-le-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://filerun.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=filerun.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/filerun.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/filerun.example.com/privkey.pem Your cert will expire on 2022-4-29. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
结论
恭喜!你已在 Debian 11 上成功安装了带有 Apache 和 Let's Encrypt SSL 的 FileRun。现在你可以使用 FileRun 存储你的文件、音乐、照片,并与你的朋友和家人分享。