1、Cloud Torrent 传统方式安装
Cloud Torrent 是用 Go 语言编写的程序,无需安装运行环境就可以直接使用。如果想用 Docker 运行或从源代码构建(需安装 Go 环境),在 GitHub 项目页有相关介绍。
这里介绍二进制文件使用方法,适用 CentOS、Debian、Ubuntu 这些主流 Linux 发行版。
安装步骤:
- 获取 Cloud Torrent,运行后会自动检测系统环境下载对应的二进制文件。
curl https://i.jpillora.com/cloud-torrent! | bash
安装后会显示程序路径,默认路径为 /usr/local/bin/cloud-torrent。
- 之后即可运行程序。
/usr/local/bin/cloud-torrent --host 0.0.0.0 --port 8000 --auth "123:123" --config-path /root/cloud-torrent.json --title "Cloud Torrent" --log >> /var/log/cloud-torrent.log
解释一下上面命令参数:监听本机 IP 使用 8080 端口,登录用户名 user 密码 password,指定程序配置文件(安装时已自动生成),设置网页标题,启用请求记录,将使用日志记录到指定文件。
根据自己需要修改选项参数,比如密码是必须要改的。完整选项可运行 cloud-torrent --help 查看。
运行后用浏览器访问你的服务器 IP 即可使用,网址格式为 http://X.X.X.X:8080/。
如果不能访问,可能防火墙没有放行端口,需要设置一下(以 CentOS 为例)。
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
- 手动运行有些麻烦,断开 SSH 会话会自动关闭。下面设置将程序放在后台运行并设置开机启动。
vi /usr/lib/systemd/system/cloud-torrent.service
# 创建服务文件,将下面内容粘贴保存。
[Unit]
Description=cloud-torrent
[Service]
# 下载目录默认为工作目录下的 /downloads 目录
WorkingDirectory=/
ExecStart=/usr/local/bin/cloud-torrent --host 0.0.0.0 --port 8000 --auth "123:123" # 加上可能报错不能启动--config-path /root/cloud-torrent.json --title "Cloud Torrent" --log >> /var/log/cloud-torrent.log
ExecStop=eval $(ps -ef | grep cloud-torrent | grep -v grep | awk '{print "kill "$2}')
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
之后就可以用下面命令管理程序了。
- 设置开机自启:systemctl enable cloud-torrent
- 取消开机自启:systemctl disable cloud-torrent
- 手动启动程序:systemctl start cloud-torrent
- 手动停止程序:systemctl stop cloud-torrent
- 查看运行状态:systemctl status cloud-torrent
2、Docker 安装 Cloud Torrent
$ docker run -d -p 3000:3000 -v /downloads:/downloads jpillora/cloud-torrent