一 克隆ipfs官网的意义
1 掌握向ipfs发布整个项目的方法(后续做详解)
发布几个页面到ipfs容易,把整个项目发布到ipfs,用哪种方法?通过对ipfs官网的研究,就能找到答案
2 在ipfs节点不多的情况下,高效处理大视频的方法(后续做详解)
通过把大视频分片打包发布到ipfs,加速大视频的播放速度,提升用户体验
3 体验开源文化、原则及精神
四大自由:自由使用、复制、修改、发行。
二 具体步骤
1 系统环境
1.1 操作系统:
[ec2-user@ip-172-31-41-45 ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.5 (Maipo)
1.2 干净的 IPFS 运行环境,且 IPFS daemon 已经成功运行
[ec2-user@ip-172-31-41-45 ~]$ ps -ef |grep ipfs
ec2-user 8875 1292 4 03:43 pts/0 00:00:15ipfsdaemon
ec2-user 8921 8892 0 03:49 pts/1 00:00:00 grep --color=autoipfs
2 克隆
2.1 安装git
[ec2-user@ip-172-31-41-45 ~]$ sudo yum install git
2.2 克隆ipfs官网原码
[ec2-user@ip-172-31-41-45 ~]$ git clone https://github.com/ipfs/website
在当前目录下有一个website ,说明克隆成功
[ec2-user@ip-172-31-41-45 ~]$ ls
website
2.3 编译
[ec2-user@ip-172-31-41-45 ~]$ cd website/
[ec2-user@ip-172-31-41-45 website]$ make
bin/bash: npm: 未找到命令
make: *** [node_modules] 错误 127
2.3 根据错误提示,安装依赖包
共需安装node.js和npm ,npm是node.js的包管理工具。我们在node.js上开发时,如果要使用别人开发的某个包(大家开发的包都打包放到nmp官网上),直接使用npm安装即可。
安装前,先安装一些依赖的包
[ec2-user@ip-172-31-41-45 website]$ sudo yum groupinstall 'Development Tools' && sudo yum install curl git m4 ruby texinfo bzip2-devel curl-devel expat-devel ncurses-devel zlib-devel
安装Linuxbrew
Homebrew最初是为Mac设计的软件包管理器,但它已经作为Linuxbrew移植到了Linux上,使得大多数开放源代码软件(如Node)的安装就像编写代码一样简单:brew install node您可以在Homebrew网站上了解更多关于Homebrew的知识,以及Linuxbrew 在Linuxbrew网站上。 要安装Linuxbrew for Linux,请打开您的终端应用程序运行命令:
[ec2-user@ip-172-31-41-45 website]$sh -c "$(curl -fsSLhttps://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)”
==>Select the Linuxbrew installation directory
-Enter your passwordto install to/home/linuxbrew/.linuxbrew(recommended)
-Press Control-Dto install to/home/ec2-user/.linuxbrew
-Press Control-Cto cancel installation
我们信任您已经从系统管理员那里了解了日常注意事项。
总结起来无外乎这三点:
#1) 尊重别人的隐私。
#2) 输入前要先考虑(后果和风险)。
#3) 权力越大,责任越大。
[sudo] ec2-user 的密码: 我是以ec2-user身份登录的系统
==>This script will install:
把LinuxBrew添到了PATH变量里:
[ec2-user@ip-172-31-41-45 website]$ test -d /home/linuxbrew/.linuxbrew && PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH”
[ec2-user@ip-172-31-41-45 website]$ test -r ~/.bash_profile && echo "export PATH='$(brew --prefix)/bin:$(brew --prefix)/sbin'":'"$PATH"' >>~/.bash_profile
安装 node 和 npm
[ec2-user@ip-172-31-41-45 website]$ brew install node
2.4 接着编译
[ec2-user@ip-172-31-41-45 website]$ make
find: ‘content/blog/static’: 没有那个文件或目录
/bin/bash: hugo: 未找到命令
make: *** [build] 错误 127
2.5 安装Hugo
[ec2-user@ip-172-31-41-45 website]$ brew install Hugo
2.6 接着编译
[ec2-user@ip-172-31-41-45 website]$ make
成功
网站建立到./public目录
2.7 把./public上传到ipfs
[ec2-user@ip-172-31-41-45 website]$ make deploy
published website:
-http://localhost:8080/ipfs/QmagYFTfAo2GPWTauwERbBbQupKcA54fX7FH5jDmBLNMLw
-https://ipfs.io/ipfs/QmagYFTfAo2GPWTauwERbBbQupKcA54fX7FH5jDmBLNMLw
next steps:
- ipfs pin add -r /ipfs/QmagYFTfAo2GPWTauwERbBbQupKcA54fX7FH5jDmBLNMLw
- make publish-to-domain
2.8 发布成功,测试
打开浏览器,输入:
http://localhost:8080/ipfs/QmagYFTfAo2GPWTauwERbBbQupKcA54fX7FH5jDmBLNMLw