私人云端硬盘Nextcloud实战

奶妈级教程👏🏻,集成化的解决方案相比自己一个一个配置安装环境工作量少太多了。

安装Ubuntu 18.04 LTS x64

Google Cloud安装Ubuntu 18.04 LTS:

Compute Engine>VM实例>创建实例

配置防火墙规则:

网络>VPC网络>防火墙规则>创建防火墙规则
名称:nextcloud
网络:default
优先等级:1000
目标标记:nextcloud
来源IP范围:0.0.0.0/0
创建

(备注:谷歌云不配置防火墙规则外部无法访问,有别于DigitalOcean和Vultr)

安装Nextcloud

下载一键安装包并安装:

$ sudo snap install nextcloud

检查安装过程是否成功:

$ snap changes nextcloud
Output
ID   Status  Spawn               Ready               Summary 
2    Done    today at 16:12 UTC  today at 16:12 UTC  Install "nextcloud" snap

配置管理员账户:

$ sudo nextcloud.manual-install username password
Output
Nextcloud is not installed - only a limited number of commands are available 
Nextcloud was successfully installed

调整信任域

查看当前信任域:

$ sudo nextcloud.occ config:system:get trusted_domains
Output
localhost

添加信任域:

$ sudo nextcloud.occ config:system:set trusted_domains 1 --value=example.com
Output
System config value trusted_domains => 1 set to string example.com

再次查看当前信任域:

$ sudo nextcloud.occ config:system:get trusted_domains
Output
localhost example.com

部署SSL安全证书

配置DNS域名解析:

TypeHostValueTTL
A Record@IP AddressAutomatic

(备注:

A记录将域名指向一个IP地址,
CNAME记录将域名指向另一个域名;

主机记录处填子域名的前缀,
example:解析后的域名为 example.domain.com
www:解析后的域名为 www.domain.com
@:直接解析主域名 domain.com

TTL为缓存时间,数值越小,修改记录各地生效时间越快。

打开防火墙中验证域所有权的端口:

$ sudo ufw allow 80,443/tcp

请求Let’s Encrypt加密证书:

$ sudo nextcloud.enable-https lets-encrypt
Output
...
... 
Have you met these requirements? (y/n)

y继续,

Output
Please enter an email address (for urgent notices or key recovery): [email protected]

输入关联域名:

Output
Please enter your domain name(s) (space-separated): example.com

大功告成,屏幕显示:

Output
Attempting to obtain certificates... done 
Restarting apache... done

登录到Nextcloud Web界面

https://example.com