Cách cài đặt FileRun trên Ubuntu 22.04

theanh

Administrator
Nhân viên
FileRun là một ứng dụng chia sẻ tệp nguồn mở và dựa trên web dành cho hệ điều hành Linux. Nó rất giống với Google Drive, iCloud và DropBox và cho phép người dùng chia sẻ và đồng bộ hóa tệp qua internet. Có thể truy cập thông qua ứng dụng di động, WebDAV và trình duyệt web. Nó cho phép bạn lưu trữ giải pháp chia sẻ tệp của riêng mình trên đám mây và truy cập tất cả các tệp của bạn ở bất kỳ đâu thông qua bộ lưu trữ đám mây an toàn.

Bài đăng này sẽ chỉ cách cài đặt FileRun với Apache và Let's Encrypt SSL trên Ubuntu 22.04.

Điều kiện tiên quyết​

  • Một máy chủ chạy Ubuntu 22.04.
  • Một tên miền hợp lệ được trỏ bằng IP máy chủ của bạn.
  • Một mật khẩu gốc được cấu hình trên máy chủ.

Cài đặt Apache, MariaDB và PHP​

FileRun được viết bằng PHP và sử dụng MariaDB làm cơ sở dữ liệu phụ trợ. Vì vậy, bạn sẽ cần cài đặt Apache, MariaDB, PHP và các gói khác vào máy chủ của mình. Trước tiên, hãy cài đặt gói Apache và MariaDB bằng lệnh sau:
Mã:
apt-get install apache2 mariadb-server mariadb-client
Sau khi cài đặt cả hai gói, bạn sẽ cần cài đặt phiên bản PHP php7.2-php7.4 trên máy chủ của mình. Tuy nhiên, Ubuntu 22.04 được tích hợp sẵn phiên bản PHP 8.1 trong kho lưu trữ mặc định. Vì vậy, bạn sẽ cần thêm kho lưu trữ PHP Ondrej vào máy chủ của mình.

Trước tiên, hãy cài đặt tất cả các phần phụ thuộc cần thiết bằng lệnh sau:
Mã:
apt install software-properties-common ca-certificates lsb-release apt-transport-https -y
Tiếp theo, hãy thêm kho lưu trữ PHP bằng lệnh sau:
Mã:
add-apt-repository ppa:ondrej/php
Tiếp theo, hãy cập nhật bộ đệm kho lưu trữ và cài đặt PHP với các phần mở rộng cần thiết khác bằng lệnh sau lệnh:
Mã:
apt update
apt install php7.4 libapache2-mod-php7.4 imagemagick ffmpeg php7.4-imagick php7.4-mysql php7.4-fpm php7.4-common php7.4-gd php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl unzip -y
Sau khi tất cả các gói được cài đặt, bạn cũng sẽ cần cài đặt trình tải IonCube vào hệ thống của mình.

Trước tiên, hãy tải xuống trình tải IonCube bằng lệnh sau:
Mã:
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
Tiếp theo, giải nén tệp đã tải xuống bằng lệnh sau lệnh:
Mã:
tar -xzf ioncube_loaders_lin_x86-64.tar.gz -C /usr/lib/php
Tiếp theo, tạo tệp cấu hình ioncube và xác định đường dẫn của nguồn IonCube:
Mã:
nano /etc/php/7.4/apache2/conf.d/00-ioncube.ini
Thêm nội dung sau dòng:
Mã:
zend_extension = /usr/lib/php/ioncube/ioncube_loader_lin_7.4.so
Lưu và đóng tệp, sau đó tạo tệp cấu hình PHP cho FileRun:
Mã:
nano /etc/php/7.4/apache2/conf.d/filerun.ini
Thêm nội dung sau cài đặt:
Mã:
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"
Lưu và đóng tệp, sau đó khởi động lại dịch vụ Apache để áp dụng các thay đổi:
Mã:
systemctl reload apache2

Tạo cơ sở dữ liệu cho FileRun​

Đầu tiên, bảo mật cài đặt MariaDB và đặt mật khẩu gốc bằng cách sử dụng lệnh sau lệnh:
Mã:
mysql_secure_installation
Trả lời tất cả các câu hỏi như hiển thị bên dưới:
Mã:
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
Tiếp theo, đăng nhập vào shell MariaDB bằng lệnh sau lệnh:
Mã:
mysql -u root -p
Sau khi đăng nhập, hãy tạo cơ sở dữ liệu và người dùng bằng lệnh sau:
Mã:
MariaDB [(none)]> CREATE DATABASE filerun;
MariaDB [(none)]> CREATE USER 'filerun'@'localhost' IDENTIFIED BY 'password';
Tiếp theo, cấp tất cả các quyền cho cơ sở dữ liệu FileRun bằng lệnh sau:
Mã:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON filerun.* TO 'filerun'@'localhost';
Tiếp theo, xóa các đặc quyền và thoát khỏi MariaDB bằng lệnh sau:
Mã:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Sau khi hoàn tất, bạn có thể tiến hành bước tiếp theo.

Tải xuống FileRun​

Đầu tiên, hãy tải xuống phiên bản mới nhất của FileRun từ trang web chính thức của họ bằng cách sử dụng lệnh sau lệnh:
Mã:
wget -O FileRun.zip https://filerun.com/download-latest
Sau khi FileRun được tải xuống, hãy giải nén tệp đã tải xuống bằng lệnh sau:
Mã:
unzip FileRun.zip -d /var/www/html/filerun/
Tiếp theo, thiết lập quyền và quyền sở hữu phù hợp bằng lệnh sau lệnh:
Mã:
chown -R www-data:www-data /var/www/html/filerun
chmod -R 755 /var/www/html/filerun
Sau khi hoàn tất, bạn có thể tiến hành bước tiếp theo.

Tạo Máy chủ ảo Apache cho FileRun​

Tiếp theo, bạn sẽ cần tạo tệp cấu hình máy chủ ảo Apache cho FileRun. Bạn có thể tạo nó bằng lệnh sau:
Mã:
nano /etc/apache2/sites-available/filerun.conf
Thêm các dòng sau:
Mã:
 ServerName filerun.example.com DocumentRoot /var/www/html/filerun  Options Indexes FollowSymLinks AllowOverride All Require all granted  ErrorLog ${APACHE_LOG_DIR}/filerun.error.log CustomLog ${APACHE_LOG_DIR}/filerun.access.log combined
Lưu và đóng tệp, sau đó kích hoạt máy chủ ảo Apache và bật mô-đun ghi đè Apache bằng lệnh sau lệnh:
Mã:
a2ensite filerun.conf
a2enmod rewrite
Tiếp theo, khởi động lại dịch vụ Apache để áp dụng các thay đổi:
Mã:
systemctl restart apache2
Bạn cũng có thể kiểm tra trạng thái Apache bằng lệnh sau lệnh:
Mã:
systemctl status apache2
Bạn sẽ thấy kết quả sau:
Mã:
? apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2022-08-06 09:26:00 UTC; 7s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 21189 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 21193 (apache2) Tasks: 6 (limit: 2242) Memory: 14.6M CPU: 112ms CGroup: /system.slice/apache2.service ??21193 /usr/sbin/apache2 -k start ??21194 /usr/sbin/apache2 -k start ??21195 /usr/sbin/apache2 -k start ??21196 /usr/sbin/apache2 -k start ??21197 /usr/sbin/apache2 -k start ??21198 /usr/sbin/apache2 -k start
Aug 06 09:26:00 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...
Sau khi hoàn tất, bạn có thể tiến hành bước tiếp theo.

Truy cập Giao diện người dùng web FileRun​

Bây giờ, hãy mở trình duyệt web của bạn và truy cập Giao diện người dùng web FileRun bằng URL . Bạn sẽ được chuyển hướng đến trang sau:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22412%22%3E%3C/svg%3E


Nhấp vào nút Tiếp theo. bạn sẽ thấy trang kiểm tra yêu cầu của máy chủ:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22439%22%3E%3C/svg%3E


Nhấp vào nút Tiếp theo. Bạn sẽ thấy trang cấu hình cơ sở dữ liệu:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22747%22%20height=%22553%22%3E%3C/svg%3E


Nhấp vào nút Tiếp theo. Sau khi quá trình cài đặt hoàn tất, bạn sẽ thấy trang sau:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22489%22%3E%3C/svg%3E


Nhấp vào nút Tiếp theo. Bạn sẽ thấy trang đăng nhập FileRun:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22370%22%3E%3C/svg%3E


Cung cấp tên người dùng quản trị, mật khẩu và nhấp vào nút Đăng nhập. Bạn sẽ thấy bảng điều khiển FileRun trên trang sau:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22365%22%3E%3C/svg%3E

Bảo mật FileRun bằng Let's Encrypt SSL​

Bạn cũng nên bảo mật trang web của mình bằng Let's Encrypt SSL. Trước tiên, bạn sẽ cần cài đặt ứng dụng khách Certbot trên máy chủ của mình. Bạn có thể cài đặt nó bằng lệnh sau:
Mã:
apt-get install python3-certbot-apache -y
Sau khi Certbot được cài đặt, hãy chạy lệnh sau để bảo mật trang web của bạn bằng Let's Encrypt SSL:
Mã:
certbot --apache -d filerun.example.com
Bạn sẽ được yêu cầu cung cấp email và chấp nhận điều khoản dịch vụ như hiển thị bên dưới:
Mã:
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): [emailprotected]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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:
Vui lòng chọn có chuyển hướng lưu lượng HTTP sang HTTPS hay không, xóa HTTP truy cập.
Mã:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
Nhập 2 và nhấn Enter để cài đặt Let's Encrypt SSL cho trang web của bạn:
Mã:
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

Kết luận​

Xin chúc mừng! Bạn đã cài đặt thành công FileRun với Apache và Let's Encrypt SSL trên Ubuntu 22.04. Bây giờ bạn có thể lưu trữ máy chủ FileRun của riêng mình trên đám mây và bắt đầu chia sẻ và đồng bộ hóa các tệp, nhạc và ảnh của mình với bạn bè và gia đình.
 
Back
Bên trên