I've been looking for a decent paste bin tool for a while now. I originally used the PasteBin source and then tried various other Ruby on Rails based alternatives. I did also use a bit of Gists which are offered by GitHub, but they seemed a bit much for a simple paste.

About 1 or 2 months ago, I caught wind of Ghostbin which I really liked. After some initial tinkering and prodding of the developer I finally got it working!

Of note, this guide is an update to this guide here!

Installing Ghostbin

First, as usual, let me plug my DigitalOcean link. It's easy and fast to get yourself up and running and perfect for using Ghostbin. I chose the basic $5/month system, and Ubuntu 14.04 x64.

Upon logging in to your new system, you'll want to add the following lines to your /etc/apt/sources.list file:

deb http://ppa.launchpad.net/bzr/ppa/ubuntu trusty main  
deb-src http://ppa.launchpad.net/bzr/ppa/ubuntu trusty main

Next run apt-get update and then apt-get install bzr mercurial git python-pygments. Next you'll want to install the Go language - apt-get install golang.

For the next part, you're not really required to do this, but I like to be organized and I prefer not to run processes as root if I can avoid it. Add a new user to your system to which you'll run Ghostbin under, adduser ghostbin. You can set a password and other information for it if you'd like. Next I switch to that user, su - ghostbin.

Next we'll update the ~/.bashrc file for the new ghostbin user account.

nano .bashrc

Add the following to the bottom of the file:

export GOPATH=$HOME/go

Then run source ~/.bashrc so that your current session is updated with the new information from the .bashrc file. Now create a couple folders:

mkdir -p ~/go/src

Now change into that new directory - cd $HOME/go/src. Create a folder called 'github.com', mkdir github.com. Go into the github.com folder, cd github.com and fetch the Ghostbin source code:

git clone https://github.com/DHowett/ghostbin.git

Go into the new folder created, cd ghostbin. At this point your full path should be something like - /home/ghostbin/go/src/github.com/ghostbin.

Now we're going to run the following commands to install the Go dependencies and such:

go get
go install
go build

Excellent, so now Ghostbin is install and ready to roll! This next bit is also optional but recommended. We'll install Nginx to proxy the requests. So as your root user run this command - apt-get install nginx. Next go into the following directory - /etc/nginx/sites-available/ and create a file called, 'ghostbin'. Open the file in your favorite text editor and add the following to it:

# Upstream configuration
upstream ghostbin_upstream {  
     server ADDRESS:PORT;
     keepalive 64;

# Public
server {  
    listen 80;
    server_name ghostbin.YOURDOMAIN.com; # domain of my site

   location / {
        proxy_http_version 1.1;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-NginX-Proxy    true;
        proxy_set_header   Host             $http_host;
        proxy_set_header   Upgrade          $http_upgrade;
        proxy_redirect     off;
        proxy_pass         http://ghostbin_upstream;

You'll want to set the ADDRESS:PORT and the server_name ghostbin.YOURDOMAIN.com; lines to match your setup. For the ADDRESS:PORT, something like would work, or even You change change the port or address to be anything which works for you. For the server_name, you should set this to your domain. In my case, I set this to:

server_name paste.linuxbox.ninja; # domain of my site

Save the file and exit your editor when done making changes. You'll then want to create a symlink of your Nginx configuration and restart the Nginx service:

ln -s /etc/nginx/sites-available/ghostbin /etc/nginx/sites-enabled/ghostbin 
service nginx restart

Now at this point you should be able to run Ghostbin and start using it. Change back into your 'ghostbin' user account (su - ghostbin) and go to /home/ghostbin/go/src/github.com/ghostbin. Then you can either run Ghostbin by using ./ghostbin -addr="ADDRESS:PORT" or you do have some other options you can set:

ghostbin@paste:~/go/src/github.com/ghostbin$ ./ghostbin --help
Usage of ./ghostbin:
  -addr="": bind address and port
  -alsologtostderr=false: log to standard error as well as files
  -log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
  -log_dir="": If non-empty, write log files in this directory
  -logtostderr=false: log to standard error instead of files
  -rebuild=false: rebuild all templates for each request
  -root="./": path to generated file storage
  -stderrthreshold=0: logs at or above this threshold go to stderr
  -v=0: log level for V logs
  -vmodule=: comma-separated list of pattern=N settings for file-filtered logging

I am currently running it as such:

ghostbin@paste:~/go/src/github.com/ghostbin$ ./ghostbin -addr="" -root="/home/ghostbin/storage" -log_dir="/home/ghostbin/logs"

You can see my Ghostbin up and running here as well as an example paste here.