Deploying ZFile with BT Panel

📢 This article was translated by gemini-3-flash-preview

This post was written on 2022.06.12. I wasn’t originally going to publish it, but since it’s fairly complete, I’m posting it for posterity. I haven’t used BT Panel or ZFile in a long time, so this guide isn’t updated and might not work perfectly with current versions.

I do not recommend using BT Panel.

Install Dependencies

Check System Version

  1. cat /etc/issue - This works for almost all Linux distributions.
1
2
3
[root@S-CentOS home]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
  1. cat /etc/redhat-release - Specifically for Redhat-based systems:
1
2
[root@S-CentOS home]# cat /etc/redhat-release
CentOS release 6.5 (Final)
  1. lsb_release -a - Lists all version details:
1
2
3
[root@S-CentOS ~]# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS

Run Commands for Your OS

1
2
3
4
5
# For CentOS
yum install -y java-1.8.0-openjdk unzip 
# For Debian/Ubuntu
apt update
apt install -y openjdk-8-jre-headless unzip

Create Site

Create the site in the panel.

Go to the site directory, open the terminal, and run:

1
2
3
wget https://c.jun6.net/ZFILE/zfile-release.war
unzip zfile-release.war && rm -rf zfile-release.war
chmod +x ./bin/*.sh

Common Commands

Run these in the site directory terminal:

1
2
3
./bin/start.sh       # Start project
./bin/stop.sh        # Stop project
./bin/restart.sh     # Restart project

Open Port

Allow port 8080 in the “Security” tab.

After starting the project, access IP:8080 to see the site.

Custom Domain

If you need HTTPS, apply for a certificate first, then enable Reverse Proxy.

In BT Panel site settings, go to “Reverse Proxy”.

Set “Target URL” to http://IP:8080 and “Sent Domain” to $host.

If deployment fails

I had issues with certain BT Panel versions. If the reverse proxy doesn’t work, try replacing the code in the “Configuration” tab of the Reverse Proxy settings with this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#PROXY-START/

location ^~ /
{
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;

    add_header X-Cache $upstream_cache_status;

    #Set Nginx Cache
    
    
    set $static_fileJA2B5K30 0;
    if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
    {
        set $static_fileJA2B5K30 1;
        expires 12h;
        }
    if ( $static_fileJA2B5K30 = 0 )
    {
    add_header Cache-Control no-cache;
    }
}

#PROXY-END/

Custom Configuration

Config file path: ./WEB-INF/classes/application.yml

Check the Official Docs - Configuration for all options.

Changing Display/Special Files

By default, ZFile looks for readme.md, but many sites use README.md.

Similarly, ZFile uses password.txt for directory passwords, while OneIndex uses .password. Renaming files manually is tedious.

Open application.yml (double-click to edit in BT Panel), press CTRL+F, search for readme, and locate this block:

1
2
3
constant:
    readme: readme.md
    password: password.txt

Change it to:

1
2
3
constant:
    readme: README.md
    password: .password

Press CTRL+S to save, then restart the project.

References

Deploying ZFile with BT Panel (Original Improved Version) - YouthMe

Linux system info commands - konglingbin - BlogGarden