Hastebin is a beautiful simple pastebin used for sharing little pieces of code or information between friends/coworkers. A friend introduced me to it about a month ago when we were trying to collaborate on a piece of batch script we were working through. After utilizing it for a couple of weeks and realizing its usability, I had the epiphany of hosting my own Hastebin! And a plus is, all collaboration is stored on one of my own machines and not out there in the wild somewhere (it helps me sleep better at night).

Enjoy!

Steps for installing a Hastebin Server

Install all necessary packages

sudo apt-get install build-essential libssl-dev redis-server git-core curl libssl-dev libcurl4-openssl-dev

Install Node Version Manager to install and maintain Node JS

git clone git://github.com/creationix/nvm.git ~/nvm
. ~/nvm/install.sh

Close Terminal and reopen

. ~/nvm/nvm.sh

Install Node JS 0.10.17 (this is the latest version as of this writing double check github.com/creationix/nvm for latest version) and Hasteserver

nvm install 0.10.17
cd ~/
git clone https://github.com/seejohnrun/haste-server.git
cd haste-server/
#If you want to change to configuration.
#I kept mine as default
nano config.js
npm install
npm start &

That is it to get you up and running. Default port will be 7777.

 

Now we can make an init script that will start Hastebin Server at boot

Create and save a text file anywhere and name it anything (mine is called pstart)

Open file and add:

#! /bin/bash
cd /root/nvm/
. ./nvm.sh
nvm use 0.10.17
cd /root/haste-server/
npm start &

Now create a directory called scripts in your /root, change permissions of your script, and move it to scripts folder

cd /root/
mkdir scripts
chmod a+x /location/of/file/pstart
cp /location/of/file/pstart /root/scripts/

Now edit your rc.local file for boot located in /etc/ directory

Open file and enter into the file before the “exit 0”

sudo /root/scripts/pstart

You are good to go and share your pastebin with others. Here is the Hastebin I built with these steps. Feel free to use it if you like.