• 欢迎访问db1024网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏db1024吧

使用Docker快速安装NextCloud个人私有云盘

建站知识 Liam 1年前 (2019-07-14) 1090次浏览 12个评论 扫描二维码
文章目录[隐藏]

说明:NexCould是一款不错,也很漂亮的个人私有云网盘,现在使用的人是越来越多了,之前发过一篇常规的搭建教程,参考:一款不错的个人私有云:NextCloud安装教程,鉴于很多人在搭建过程中或多或少都会出点问题,今天博主发个很方便的安装方法,就是用Docker安装NextCloud,看到网上很多这样的教程都是通过编辑docker-compose.yml文件来安装的,还要配置反向代理,期间容易出现很多问题,对新手很不友好,而本教程使用纯命令形式安装,不容易出问题,适合尝鲜的新手。

截图

使用Docker快速安装NextCloud个人私有云盘
使用Docker快速安装NextCloud个人私有云盘

更新

Docker镜像已替换成更新比较频繁,体积更加小的镜像,使用的是最新稳定版Alpine Linux,环境为PHP 7Nginx

安装

Github地址:https://github.com/chrootLogin/docker-nextcloud

1、安装Docker

#CentOS 6 rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum update -y yum -y install docker-io service docker start chkconfig docker on  #CentOS 7、Debian、Ubuntu curl -sSL https://get.docker.com/ | sh systemctl start docker systemctl enable docker 

2、安装Nextcloud

#拉取Mysql镜像,记得修改数据库信息 docker run --name mysqlnc -d  -p 3306:3306  -e MYSQL_ROOT_PASSWORD=moerats  -e MYSQL_DATABASE=moerats  -e MYSQL_USER=moerats  -e MYSQL_PASSWORD=moerats  -v /root/nextcloud/mysql:/var/lib/mysql  mysql:5.7  #拉取Nextcloud镜像 docker run -d --name nextcloud --link mysqlnc  -v /root/nextcloud/data:/data  -p 3000:80  rootlogin/nextcloud 

访问地址为http://IP:3000,启动命令里的3000端口可自行替换,不过后面有关端口的命令都自行修改,/root/nextcloud为网盘的数据库,也可以自行修改。

对于CentOS系统,还需要开启3000端口,开启如下:

#CentOS 6 iptables -I INPUT -p tcp --dport 3000 -j ACCEPT service iptables save service iptables restart  #CentOS 7 firewall-cmd --zone=public --add-port=3000/tcp --permanent firewall-cmd --reload 

如果要用域名访问,就需要反代了。

域名访问

反代可以用NginxApacheCaddy,这里只说宝塔和Caddy。如果你网站有宝塔,就可以使用宝塔进行反代,如果没有,建议使用第2种的Caddy反代,配置很快。

1、宝塔反代
先进入宝塔面板,然后点击左侧网站,添加站点,然后再点击添加好了的域名名称,这时候就进入了站点配置,点击反向代理,目标URL填入http://127.0.0.1:3000,再启用反向代理即可。至于启用SSL就不说了,直接在站点配置就可以启用。

2、Caddy反代
安装Caddy

wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh #备用地址 wget -N --no-check-certificate https://www.moerats.com/usr/shell/Caddy/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh 

配置Caddy

#以下全部内容是一个整体,请修改域名后一起复制到SSH运行!  #http访问,该配置不会自动签发SSL echo "xx.com {  gzip  proxy / 127.0.0.1:3000 {     header_upstream Host {host}     header_upstream X-Real-IP {remote}     header_upstream X-Forwarded-For {remote}     header_upstream X-Forwarded-Proto {scheme}   } }" > /usr/local/caddy/Caddyfile  #https访问,该配置会自动签发SSL,请提前解析域名到VPS服务器 echo "xx.com {  gzip  tls [email protected]  proxy / 127.0.0.1:3000 {     header_upstream Host {host}     header_upstream X-Real-IP {remote}     header_upstream X-Forwarded-For {remote}     header_upstream X-Forwarded-Proto {scheme}   } }" > /usr/local/caddy/Caddyfile 

tls参数会自动帮你签发ssl证书,如果你要使用自己的ssl,改为tls /root/xx.crt /root/xx.key即可。后面为ssl证书路径。

启动Caddy

/etc/init.d/caddy start

就可以打开域名进行访问了。

3、Nginx配置
如果你使用其它的,这里就大概发个Nginx反代配置,直接添加到配置文件即可。

#在配置文件里添加 location / {      proxy_pass http://127.0.0.1:3000;      proxy_redirect off;      proxy_set_header X-Real-IP $remote_addr;      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;     } 

最后要注意的是,安装的时候,Mysql数据库地址填localhost:3306


db1024 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:使用Docker快速安装NextCloud个人私有云盘
喜欢 (0)
关于作者:
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(12)个小伙伴在吐槽
  1. Hey there just wanted to give you a quick heads up. The words in your post seem to be running off the screen in Safari. I'm not sure if this is a formatting issue or something to do with browser compatibility but I thought I'd post to let you know. The layout look great though! Hope you get the issue solved soon. Cheers
    best web hosting company2020-09-05 20:05 回复 Mac OS X | Chrome 65.0.3325.181
  2. Excellent post. I was checking continuously this blog and I am impressed! Very useful info specially the last part : ) I care for such information much. I was looking for this certain information for a long time. Thank you and best of luck.
    web hosting providers2020-08-31 21:28 回复 Mac OS X | Chrome 65.0.3325.181
  3. This article will help the internet users for building up new blog or even a weblog from start to end.
    black mass2020-08-31 13:15 回复 Mac OS X | Chrome 52.0.2777.85
  4. I have been browsing online greater than 3 hours as of late, but I never discovered any interesting article like yours. It's lovely price sufficient for me. In my view, if all website owners and bloggers made just right content material as you did, the internet will be a lot more useful than ever before.
    black mass2020-08-28 22:59 回复 Mac OS X | Firefox浏览器 59.0
  5. Great goods from you, man. I have understand your stuff previous to and you are just too wonderful. I really like what you've acquired here, really like what you are saying and the way in which you say it. You make it enjoyable and you still take care of to keep it sensible. I cant wait to read much more from you. This is actually a wonderful website.
    cheap flights2020-08-28 07:30 回复 Linux | Firefox浏览器 52.9
  6. Thanks very nice blog! 3aN8IMa cheap flights
    cheap flights2020-08-26 18:09 回复 Linux | Chrome 67.0.3372.0
  7. This article offers clear idea for the new viewers of blogging, that in fact how to do blogging. 2CSYEon cheap flights
    cheap flights2020-08-26 09:28 回复 Windows 7 | Internet Explorer 9.0
  8. Hi! This is my first comment here so I just wanted to give a quick shout out and tell you I really enjoy reading your posts. Can you suggest any other blogs/websites/forums that go over the same topics? Thanks a ton! cheap flights 32hvAj4
    cheap flights2020-08-25 10:02 回复 Linux | 未知浏览器
  9. Hi there just wanted to give you a quick heads up. The words in your content seem to be running off the screen in Ie. I'm not sure if this is a formatting issue or something to do with web browser compatibility but I thought I'd post to let you know. The layout look great though! Hope you get the problem fixed soon. Cheers cheap flights yynxznuh
    cheap flights2020-08-25 08:21 回复 Windows 8.1 | Firefox浏览器 60.0
  10. magnificent post, very informative. I wonder why the other specialists of this sector don't realize this. You must continue your writing. I'm sure, you have a great readers' base already! cheap flights 34pIoq5
    cheap flights2020-08-24 21:46 回复 Mac OS X | Safari浏览器 601.1.27
  11. Thanks in favor of sharing such a nice idea, piece of writing is fastidious, thats why i have read it completely
    best web hosting company2020-08-14 07:17 回复 Windows 7 | Internet Explorer 10.0
  12. Very good blog! Do you have any helpful hints for aspiring writers? I'm planning to start my own blog soon but I'm a little lost on everything. Would you recommend starting with a free platform like Wordpress or go for a paid option? There are so many options out there that I'm completely overwhelmed .. Any recommendations? Many thanks! adreamoftrains webhosting
    adreamoftrains best web hosting sites2020-08-10 13:32 回复 未知操作系统 | Chrome 66.0.3359.181