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.
So can you give me some more examples of why someone would use this? I’m a little confused. Is it like pintresest except private instead of public. only for those invited?
Haha!!! Its far more nerdier than that. Its all just text, mostly used for sharing computer programming code snippets.
Hi Sergio,
Thanks for the post.
Can you clarify one thing for me since I’m not savvy with Linux? I love hastebin and would love to take the concept further with a private server. However, I’m a bit concerned about security and how to share with friends. Say I want to share a paste with a friend over the network. I would need to open have port 80 open so people can navigate to the server right?
Does the hastebin installer take care of the webserver aspect too? What webserver is it? Is it apache? How do install and configure that part?
Thank you
J
I meant share with a friend over the internet – not over the intranet.
Hello John,
Opening a port on your router is what will make it accessible via internet. By default, the server configuration is set to Port 7777 not port 80. Once you build server you can configure to any port in the config.js file in Haste-server folder. The easiest less fluid way others would be able to access it would be your public IP and port number. EX: 101.102.103.104:7777 the other way would be the get a domain name service and point DNS record to your IP so instead of users having to remember IP address you can give them a domain name instead.
It runs using Node.js environment. No apache necessary. This was my first exposure to Node.js so I don’t know too much about it.
Just like you, John, I am not that great in Linux. This is super simple and a fun to create. I suggest you take a crack at it! Let me know how things go. Happy command lining!
Hello.
I have one small query.
i have done above steps on a Amazon EC2 instance.
After that i edited the config.js to host at my instance’s public IP
and port 7777, but still i am not able to get it to open on
54.66.253.170:7777
Any suggestions would be much appreciated.
br
s
Edit :
Just realized changing the host to my ip and npm start gives me a error
http://www.hastebin.com/etubiwajum.avrasm