阿里云网盘是最近两年比较热门的网盘,看名字就知道是阿里云旗下的,网盘开始是说免费,嗯,不过目前开始收费了,不过怎么说呢,个人反而觉得比较安心,毕竟我是不相信天下有免费的午餐的!
因为阿里云网盘支持WebDAV协议,因为本人刚好有这方面的需求,所以开始折腾,但网上的教程让我受伤了很久,因为有的教程已经失效了,所以自己写下这一篇文章,其主要目的是为了方便自己后期再次部署,当然也希望能够帮助其他朋友避坑!那么,我们就正式开始吧:
第一步:安装宝塔
安装好centos系统之后,直接使用以下命令安装,这个挺基础的,在这里也就不多说,因为我们是针对centos系统来说,所以这里就是放该系统的安装命令:
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh ed8484bec
第二步:安装Docker
因为我们使用的是宝塔面板,所以我们就使用宝塔的插件安装便好,具体方法如下:
第三步,获取阿里云盘的refreshToken
手动获取: 登录阿里云盘后,可以在开发者工具 -> Application -> Local Storage 中的 token
字段中找到。注意:不是复制整段 JSON 值,而是 JSON 里 refresh_token
字段的值,如下图所示红色部分:
这一步用文字来说明比较复杂,看图更简单:
第四步,搭建WebDAV
登陆ssh,并在ssh中输入以下命令,拉取镜像
docker pull messense/aliyundrive-webdav
拉取之后,我们就需要启动镜像,具体命令如下:
docker run -d --name=aliyundrive-webdav --restart=unless-stopped -p 8080:8080 \ -v /etc/aliyundrive-webdav/:/etc/aliyundrive-webdav/ \ -e REFRESH_TOKEN='your refresh token' \ -e WEBDAV_AUTH_USER=admin \ -e WEBDAV_AUTH_PASSWORD=admin \ messense/aliyundrive-webdav
然后我们需要检测镜像是否运行成功,我们可以在面板中看运行状态便可:
类似这样说明运行正常,如果没有运行正常,我们需要注意一个事,就是您的端口是否正常开通,这是一个很重要的细节问题。
第五步,使用Rclone挂载阿里云盘
①下载脚本
curl https://rclone.org/install.sh | sudo bash
②初始化脚本
rclone config
③启动后可以看到如下:
No remotes found, make a new one? n) New remote s) Set configuration password q) Quit config n/s/q> n name> onedrive
④输入 n 新建一个配置,name 为你的配置名称,可以自定义,这里我输入的是aliyunpan
No remotes found, make a new one? n) New remote s) Set configuration password q) Quit config n/s/q> n name> aliyunpan
然后会出现挂载的服务类型,如下:
Option Storage. Type of storage to configure. Choose a number from below, or type in your own value. 1 / 1Fichier \ (fichier) 2 / Akamai NetStorage \ (netstorage) 3 / Alias for an existing remote \ (alias) 4 / Amazon Drive \ (amazon cloud drive) 5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Lyve Cloud, Minio, RackCorp, SeaweedFS, and Tencent COS \ (s3) 6 / Backblaze B2 \ (b2) 7 / Better checksums for other remotes \ (hasher) 8 / Box \ (box) 9 / Cache a remote \ (cache) 10 / Citrix Sharefile \ (sharefile) 11 / Compress a remote \ (compress) 12 / Dropbox \ (dropbox) 13 / Encrypt/Decrypt a remote \ (crypt) 14 / Enterprise File Fabric \ (filefabric) 15 / FTP Connection \ (ftp) 16 / Google Cloud Storage (this is not Google Drive) \ (google cloud storage) 17 / Google Drive \ (drive) 18 / Google Photos \ (google photos) 19 / Hadoop distributed file system \ (hdfs) 20 / Hubic \ (hubic) 21 / In memory object storage system. \ (memory) 22 / Jottacloud \ (jottacloud) 23 / Koofr, Digi Storage and other Koofr-compatible storage providers \ (koofr) 24 / Local Disk \ (local) 25 / Mail.ru Cloud \ (mailru) 26 / Mega \ (mega) 27 / Microsoft Azure Blob Storage \ (azureblob) 28 / Microsoft OneDrive \ (onedrive) 29 / OpenDrive \ (opendrive) 30 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ (swift) 31 / Pcloud \ (pcloud) 32 / Put.io \ (putio) 33 / QingCloud Object Storage \ (qingstor) 34 / SSH/SFTP Connection \ (sftp) 35 / Sia Decentralized Cloud \ (sia) 36 / Storj Decentralized Cloud Storage \ (storj) 37 / Sugarsync \ (sugarsync) 38 / Transparently chunk/split large files \ (chunker) 39 / Union merges the contents of several upstream fs \ (union) 40 / Uptobox \ (uptobox) 41 / Webdav \ (webdav) 42 / Yandex Disk \ (yandex) 43 / Zoho \ (zoho) 44 / http Connection \ (http) 45 / premiumize.me \ (premiumizeme) 46 / seafile \ (seafile)
这里我们选择41,我们通过webdav协议加载阿里云盘(不通版本可能有不通,记住是Webdav便可)
①填写http://127.0.0.1:8080
②选择5
③输入admin回车
④y,自己设置密码;
⑤在bearer_token后面回车
⑥不需要高级配置,输入n回车;
⑦y回车
⑧q回车退出配置
如果,我们就完成了阿里云的Webdav挂载了,然后我们需要做的是将Webdav盘挂载到服务器,具体流程如此:
rclone 挂载依赖于 fuse,需要先安装好:
#CentOS 7安装fuse yum -y install fuse
然后执行挂载操作:
#创建挂载点 mkdir -p /home/aliyunpan #挂载Drive到/home/aliyunpan rclone mount aliyunpan:/ /home/aliyunpan --allow-other --attr-timeout 5m --vfs-cache-mode full --vfs-cache-max-age 24h --vfs-cache-max-size 10G --vfs-read-chunk-size-limit 100M --buffer-size 100M --daemon ———————————————— aliyunpan为Rclone的配置名称,比如你配置rclone的时候,Name填的aliyunpan Folder为网盘里的文件夹路径,如果你要挂载整个网盘,直接填 / 挂载整个根目录
如此,我们便可以在服务器上挂载的硬盘了!
评论(0)