Last Updated: February 25, 2016
·
1.126K
· dallas

rbserv—a simple Ruby HTTP server

I use this one all the time to get a simple HTTP server up-and-running very quickly for any "static" website which may have URLs for images and such that are pseudo-absolute (e.g. src="/images/some-image.jpg"). Personally I use OhMyZSH! and I have this little snippet in my custom/aliases.zsh file.

# Ruby using HTTPD
# Override the port number by passing in a 2nd -p option:
#   rbserv -p 8080
alias rbserv='ruby -run -e httpd . -p 8000'

With that in place, you just need to cd into the root/public directory of the site and run rbserv to get it up-and-running on http://localhost:8000 (be default). You can pass a second -p (port) option to override the 8000 part (like if you have more than 1 running at a time).