当前位置:网站首页>使用ECS和OSS搭建个人网盘
使用ECS和OSS搭建个人网盘
2022-07-26 18:49:00 【量子波动猫】
一、创建ECS服务器:

二、安装Cloudreve
1.下载cloudreve安装包。
wget https://labfileapp.oss-cn-hangzhou.aliyuncs.com/cloudreve_3.3.1_linux_amd64.tar.gz

2.下载完毕后,解压cloudreve安装包。
tar -zxvf cloudreve_3.3.1_linux_amd64.tar.gz
3.给cloudreve授予权限。
chmod +x ./cloudreve
4.运行cloudreve。
./cloudreve

5.打开浏览器,访问http://47.101.179.36:5212,依次输入管理员账号和密码,单击登录。

三、安装ossfs
ossfs能让您在Linux系统中,将对象存储OSS的存储空间(Bucket)挂载到本地文件系统中,能够像操作本地文件一样操作OSS的对象(Object),实现数据的共享。
1.下载ossfs安装包。
wget https://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_centos8.0_x86_64.rpm
2.更换yum源
[[email protected] ~]# rm -f /etc/yum.repos.d/* #1.先删除系统内过期的.repo文件
[[email protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo #2.载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
[[email protected] ~]# yum clean all && yum makecache #3.运行 yum makecache 生成缓存
3.下载完毕后,执行如下命令,安装ossfs。
yum install -y ./ossfs_1.80.6_centos8.0_x86_64.rpm

4.配置账号访问信息,将Bucket名称以及具有此Bucket访问权限的AccessKey ID和AccessKey Secret信息存放在/etc/passwd-ossfs文件中。您需要将BucketName、yourAccessKeyId和yourAccessKeySecret替换成Bucket名称、AccessKey ID和AccessKey Secret。
#echo BucketName:yourAccessKeyId:yourAccessKeySecret > /etc/passwd-ossfs
[[email protected] ~]# echo zax-cloud:LTAI5t6jDKNMT3YhyGVSb95h:d0N7KwV1LC5BHvZsbDgmkWrHo87WbR > /etc/passwd-ossfs
参数说明:
- BucketName:阿里云OSS控制台中创建的bucket名称。
- yourAccessKeyId:具有此Bucket访问权限的AccessKey ID。
- yourAccessKeySecret:具有此Bucket访问权限的AccessKey Secret。
5.给passwd-ossfs文件授予权限。
chmod 640 /etc/passwd-ossfs
四、挂载OSS
1.创建一个名为oss文件夹。
mkdir oss
2.将Bucket挂载到指定目录oss,需要将BucketName、mountfolder和Endpoint替换成bucket名称、创建的oss文件夹和OSS的ECS 的经典网络访问(内网)的Endpoint。
#ossfs BucketName oss -o url=Endpoint
[[email protected] ~]# ossfs zaxs oss -o url=oss-cn-shanghai-internal.aliyuncs.com
3.查看是否挂载成功
df -h

4.在/etc/init.d/目录下建立文件ossfs,设置开机自动启动脚本进行OSS挂载。
vim /etc/init.d/ossfs
5.进入Vim编辑器后,按下i键进入编辑模式,添加以下内容,添加完成后按下Esc键退出编辑模式,最后输入:wq后按下Enter键,保存并退出Vim编辑器。
#! /bin/bash
#
# ossfs Automount Aliyun OSS Bucket in the specified direcotry.
#
# chkconfig: 2345 90 10
# description: Activates/Deactivates ossfs configured to start at boot time.
ossfs zaxs oss -o url=oss-cn-shanghai-internal.aliyuncs.com -oallow_other
6.为新建立的ossfs脚本赋予可执行权限。
chmod a+x /etc/init.d/ossfs
7.把ossfs启动脚本作为其他服务,开机自动启动。
chkconfig ossfs on
五、配置个人网盘
运行cloudreve。
./cloudreve
打开浏览器,访问http://<ECS公网地址>:5212,依次输入管理员账号和密码,单击登录。
在cloudreve主界面右上角,单击管理面板。
在确定站点URL设置对话框中,单击更改。
在左侧导航栏中,单击存储策略。
在存储策略页面,单击添加存储策略。
在选择存储方式对话框中,选择本机存储。
在添加本机存储策略的上传路径页面中,将存储目录修改为oss/Object路径/{uid}/{path},单击下一步。

在添加本机存储策略的直链设置页面中,单击下一步。

在添加本机存储策略的上传限制页面中,单击下一步。

在添加本机存储策略的完成页面中,输入存储策略名OSS,单击完成。

在左侧导航栏中,单击用户组。
在用户组页面中,单击管理员操作中的编辑图标。
在编辑管理员页面的存储策略中,选择oss,然后单击保存。
在用户组的右上角,单击返回主页。
在个人网盘页面,拖拽任意文件到网页中,待文件上传完毕,关闭上传队列。

浏览器打开oss控制台,在左侧导航栏中,通过Bucket列表,点击对应的Bucket名称,然后单击文件管理。
然后就可以看到在个人网盘上传的文件。

边栏推荐
- DDL, DQL, DML statements
- Where can I find the files downloaded from iPad
- [PHP] common header definitions
- Bug 反馈:同步失败
- Detailed explanation of Yolo V2
- Volatile keyword of JVM memory model
- Aof & RDB of J2 redis
- Live video source code to achieve the advertising effect of scrolling up and down
- Leetcode-138-copy linked list with random pointer
- LeetCode每日一练 —— 26. 删除有序数组中的重复项
猜你喜欢

DOM案例:10秒倒计时-写跳转页面相关的知识

Win11 U盘驱动异常怎么调整为正常?

基于ABP实现DDD--领域逻辑和应用逻辑

企业内部信息碎片化该怎么办?不妨试试这样做
![Design of intelligent weighing system based on Huawei cloud IOT (STM32) [II] there is information at the end](/img/55/ca86fd1a53eb61efc70fead08ff0ad.png)
Design of intelligent weighing system based on Huawei cloud IOT (STM32) [II] there is information at the end

浅析接口测试

Redis introduction

Pyqt5 rapid development and practice 3.6 packaging resource files

What is a knowledge management system? You need to know this

Training embedded representation of large categories using triple loss and twin neural networks
随机推荐
iPhone开发 数据持久化总结(终结篇)—5种数据持久化方法对比
MySQL 子查询使用方式
【PHP】使用 file_get_contents() 发送 GET、POST 请求
【PHP】将 SESSION 数据保存到 Redis
Live video source code to achieve the advertising effect of scrolling up and down
Adjust the array order so that odd numbers precede even numbers and their relative positions remain the same
canvas概述
Redis6
UIAutomator2常用类之UiObject2
金仓数据库 KingbaseES SQL 语言参考手册 (19. SQL语句: DROP TABLE 到 LOAD)
NLP learning path
CIO guide to business change
Redis介绍
LeetCode每日一练 —— 88. 合并两个有序数组
【PHP】常用的header头部定义
论文精读:YOLOV2——YOLO9000:Better, Faster, Stronger
Leetcode daily practice - 189. Rotation array
How to uninstall win11 edge? The method tutorial of completely uninstalling win11 edge browser
Bug 反馈:同步失败
2022/07/26 学习笔记 (day16) 链表和栈