How to setup a IPFS network in Ubuntu
In this article we will see how to setup IPFS network in an Ubuntu machine/System. we will go step by step in this article if you did not saw our Intro to IPFS we recommend to see this first.
In this we setup a public IPFS network.
step 1. Install go
* download go zip file from there official website https://golang.org/dl/
* Create a new folder, then copy the downloaded file into this folder.
* open terminal in current directory ("the directory which we created 'work folder' ")
* type " sudo tar -C /usr/local -xzf go1.12.7.linux-amd64.tar.gz " : this command will extract the file into the /usr/local folder, Note: in our case we have go1.12.7.linux-amd64.tar.gz file if you have any different version then use that file name instead of go1.12.7.linux-amd64.tar.gz.
* type " export PATH=$PATH:/usr/local/go/bin " : the export command marks an environment variable to be exported with any newly forked child processes, in this line $PATH variable will be updated with new value /usr/local/go/bin/ .
* type " source $HOME/.profile " : source command will bring the given file into the shell script , in this .profile will be loaded in current shell script .
* type " go version " : to check the go version.
step 2 : Install IPFS
* open terminal in current directory " work folder ".
* type " sudo apt-get update ".
* go to official website of IPFS by clicking here then right click on download button and copy the address .
* in terminal type " wget paste_the_copied_URL " : this will download a zip file in current directory.
* type " ls " to see the downloaded file.
* type " tar xvfz downloaded_file_name " : this will unzip file.
* type " sudo mv go-ipfs/ipfs /usr/local/bin/ipfs " : this command will move the ipfs file from current directory to /usr/local/bin/ipfs.
* clean unnecessary files and folders : type : " sudo rm -rf go-ipfs " .
* type : " ipfs version " : for checking the ipfs version installed .
* type : " ipfs init " : we need to initialize the ipfs file, it required once at the time of installation after this we not need to run this command again. This command will return a peer ID which is a unique identification of each peer.
step 3 : establishing network and deploying file to it.
* create a folder( "project" ) then create a new text file ("first.txt") in the folder save the text file with some content ( "hello world").
* open two terminals in current directory
* in first terminal type " ipfs daemon " : it will start a thread process to provide a ipfs gateway for accessing/deploying yours file over the network. leave this terminal as it is.
* in 2nd terminal type : " ifps swarm peers " : this command will list all the peers you connected with through internet.
* type : " ls " check your file in your current folder.
* type " ipfs add filename.extensionName " eg . " ipfs add first.txt " :
this will add file to the ipfs network and return the hash value for accessing this file data.
a* copy the returned hash value and type : " ipfs cat paste_hash " : this will output the content of file .
b* publish your file over the network : type : " ipfs name publish paste_hash" : this will publish your file over the network and return a string like this "ipfs/your_hash_value" then copy this value.
c* open your browser and type " localhost:8080/paste_value_here" eg : 'localhost:8080/ipfs/hashValue'
--------------------------------------------------------------------------------------------------------------------
* instead of a file if you want to add a whole folder then follow the following commands .
* navigate to your folder parent directory through terminal , type : " ls " to see your folder.
* type : " ipfs add -r folderName " : this will recursively add your folder to the ipfs. It will return the bunch of hashes according to number of file in the folder , just copy the last hash it is the hash of root folder then follow the a*, b* and c* steps.
--------------------------------------------------------------------------------------------------------------------------
Thanks for reading this article in future posts we are going to see how to setup a private ipfs network















Comments
Post a Comment