Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Blog post detailing quick install of IPFS latest #8

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
81 changes: 81 additions & 0 deletions src/2-run-ipfs-on-a-vps/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
baseurl: ..
template: tmpl/layouts/post.html
breadcrumbs:
- {name: "2-run-ipfs-on-a-vps", link: "./" }
id: 2-run-ipfs-on-a-vps
date: 2015-11-02
title: Run IPFS latest on a VPS
author: Kyle Drake
collection: posts
---

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would LOVE to have an https://asciinema.org of this whole thing, so people can watch it, and follow along.

can use this package https://github.com/jbenet/asciinema-selfhost to re-host it to ipfs so you dont have to rely on asciinema. see https://github.com/jbenet/asciinema-selfhost#show-me (it can be iframe embeded, just github issues doesnt let us)

The best way to provide content using [IPFS](https://ipfs.io) is to run your own IPFS node. You can do this by running an IPFS node on your personal computer, but that will only work as long as your computer is running. For users running mostly from laptops or with bandwidth constraints, it is useful to run IPFS nodes in a datacenter, and pinning the content there too. This ensures your content is replicated, online, and available to other nodes on the network.

VPS instances provided by [Digital Ocean](https://www.digitalocean.com/), [Ramnode](http://ramnode.com/), [Linode](https://www.linode.com/), [Vultr](https://www.vultr.com/) and many other providers allow you to quickly setup your own Linux server with the reliability of a managed dedicated server without the full cost. This is a quick guide to setting up your own dedicated IPFS node on a VPS. We'll be using [Ubuntu](http://www.ubuntu.com/) 14.04LTS 64-bit for the example.

First, let's get the packages we'll need to install IPFS:

apt-get update
apt-get install unzip wget

Now you can download the latest build of IPFS from the [install page](https://ipfs.io/docs/install/). We'll be using Linux x86_64:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show how to pick the architecture.

actually, this script does it for them:

maybe worth using that? (or showing both)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whyrusleeping how do users download ipfs-update in a one-liner? we need something like https://github.com/ipfs/ipfs-update -- we really need ipget or something to install first to pull all the other things in a secure way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gobuilder.me/github.com/ipfs/ipfs-update

Downloading from there is the only easy way right now (other than go get). I could probably make a quicky shell script for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap, was thinking about copying most of that


wget https://gobuilder.me/get/github.com/ipfs/go-ipfs/cmd/ipfs/ipfs_master_linux-amd64.zip
unzip ipfs_master_linux-amd64.zip
cp ipfs/ipfs /usr/local/bin/

It's usually not a good idea to run a public-facing service as root. So we'll create a user account to run IPFS in and switch to it:

adduser ipfs
su ipfs

First let's initialize the IPFS config:

ipfs init

This generates a basic IPFS config file for your user.

IPFS works by actively seeking nearby nodes to connect to, which is a good thing for performance and availability, particularly in home and office networks. This causes addresses in the networks to be dialed that may not be there. Unfortunately, some VPS providers incorrectly classify this as suspicious activity, and some even have blocked nodes for doing so. To avoid this, let's add two things to the config file:

# 1. disable mDNS discovery
ipfs config --json Discovery.MDNS.Enabled false

# 2. filter out local network addresses
ipfs config --json Swarm.AddrFilters '[
"/ip4/10.0.0.0/ipcidr/8",
"/ip4/100.64.0.0/ipcidr/10",
"/ip4/169.254.0.0/ipcidr/16",
"/ip4/172.16.0.0/ipcidr/12",
"/ip4/192.0.0.0/ipcidr/24",
"/ip4/192.0.0.0/ipcidr/29",
"/ip4/192.0.0.8/ipcidr/32",
"/ip4/192.0.0.170/ipcidr/32",
"/ip4/192.0.0.171/ipcidr/32",
"/ip4/192.0.2.0/ipcidr/24",
"/ip4/192.168.0.0/ipcidr/16",
"/ip4/198.18.0.0/ipcidr/15",
"/ip4/198.51.100.0/ipcidr/24",
"/ip4/203.0.113.0/ipcidr/24",
"/ip4/240.0.0.0/ipcidr/4"
]'

Now you're ready to start IPFS!

ipfs daemon &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show the expected output of this (and probably every command, if there is any)


Give it a minute to connect to some other IPFS nodes, and then test that it's working by running a quick test:

echo "hello world" | ipfs add

This will return the hash `QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o`. Now run this command to make sure that your IPFS node has pinned this content:

ipfs refs local | grep QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is technically that "the IPFS node has this content locally". to check for a pin use ipfs pin ls


And you should see a response with the same hash.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just show the output, too. a good way is this:

> # check we have the content locally
> ipfs refs local | grep QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o

or even using $ ?

$ # check we have the content locally
$ ipfs refs local | grep QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o


If you want to have IPFS boot at startup, add an entry to `/etc/rc.local`. You can run this command as root to quickly add it:

sed -i -e '$i /bin/su ipfs -c "/usr/local/bin/ipfs daemon &"\n' /etc/rc.local

This process will simplify in the future when IPFS starts being packaged with distributions (`apt-get install ipfs`). But until then, this will get you started with IPFS experimentation on your own server. Run `ipfs help` to get a list of things you can do, and let us know if you run into any issues.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also have proper init scripts, may be worth mentioning them -- https://github.com/ipfs/examples/tree/master/examples/init may be worth using the upstart one or whatever ubuntu ships with these days