如何在本地搭建私有云盘(Nextcloud)

如果你没有本地NAS,又想拥有一个自己的云盘那你可以在Linux上部署一个开源免费的个人云盘项目Nextcloud(https://nextcloud.com)我这里使用的Debian 12,Ubuntu 24.04也同样适用

1.安装Docker(如果已经安装,请忽略

sudo apt update  
sudo apt upgrade -y  
#安装软件以来
sudo apt install ca-certificates curl gnupg apt-transport-https gpg
#下载GPG密钥并写入系统
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" |tee /etc/apt/sources.list.d/docker.list > /dev/null 
#更新软件包
sudo apt update
#安装Docker
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose
#最后验证是否安装成功并且是否开机自启动
systemctl is-active docker

2.安装nextcloud

#拉取Nextcloud镜像
docker pull nextcloud
#等待下载(国内目前已经解封Docker)
#如果显示以下内容即代表拉取成功
Using default tag: latest
latest: Pulling from library/nextcloud
bc51dd8edc1b: Pull complete
a3224e2c3a89: Pull complete
be7a066df88f: Pull complete
bfdf741d72a9: Pull complete
a9e612a5f04c: Pull complete
c026d8d0e8cb: Pull complete
d94096c4941c: Pull complete
5a16031a7587: Pull complete
0cf1daf9efc0: Pull complete
b202acb13a6c: Pull complete
907001e30880: Pull complete
2e4b329c80b2: Pull complete
cd1ec92e7164: Pull complete
8cba435f5ca6: Pull complete
e15a177658f6: Pull complete
9b26736059ce: Pull complete
53dbece8c17a: Pull complete
07158f924c2a: Pull complete
5ea6266119b8: Pull complete
e377a8cc542f: Pull complete
5662efc30cde: Pull complete
Digest: sha256:fa863d16c10387f4bae140bdd38f5591aa4b88f1292593dcffa501b9e1a76e58
Status: Downloaded newer image for nextcloud:latest
docker.io/library/nextcloud:latest

3.启动Nextcloud容器

sudo docker run -d --restart=always --name nextcloud -p 9001:80 nextcloud

上述代码中:

  • docker run :启动容器
  • -d :后台运行此容器
  • --restart=always :跟随docker一起重启
  • --name nextcloud :容器的名字
  • -p 9001:80 :将容器的9001端口映射到主机的80
  • nextcloud :是启动的容器名字

运行后如果出现一串长的字符串则说明启动成功

4.在本地连接测试

上述操作完成后就可以使用浏览器访问本机IP:9001(如果没有部署其他服务也可以直接访问IP)

可以自行选择数据库类型,我只是作为一个本地云盘使用所以使用SQLite(主要是方便)

创建账号和密码,点击安装 最后登陆即可

如何在本地搭建私有云盘(Nextcloud)

感谢你的阅读

若汐

评论

  1. 9 月前
    2024-9-28 0:56:30

    好好好

本文评论已关闭
上一篇
下一篇