That was hard

Written by Michael Lee on September 12, 2016

As developer, I’ve shied away from setting up my own server. I’ve done it before but for the amount of time spent and not knowing what all the pieces were for, I felt the server I did eventually setup was so volatile.

Recently I’ve been working on a Rails app that needed to be hosted somewhere. The easy place to host it would be Heroku. Unfortunately to host a Rails app and have a PostgreSQL db with SSL on a custom domain would cost ~$50/month. As this app is part of a business with zero paying customers currently, I just couldn’t stomach that cost right now.

My motto has always been to keep things as lean as possible and that includes financial resources used to run a business. It was this way back when I ran Print Squares and it still is today.

For this reason, I decided to give setting up a Digital Ocean VPS to run my Rails app, a shot. I’ve setup an nginx server before to run my personal site and the experience wasn’t so bad. Paired with letsencrypt, the cost to run a site on a VPS can cost as low as $5/month. I’ve also grown more familiar with vim and tmux, so I felt more confident that I would be able to set up a server a bit quicker with less head-banging on the wall this time around.

Keeping with my lean motto, I moved my personal site over to GitLab Pages. The reason for this is that, GitLab Pages supports SSL on custom domains for free. Doing this freed up some financial resources to spin up a VPS for the Rails app. Once, the business is cash-flow positive, I plan on spinning up another Digital Ocean VPS to host my personal site again. But for now, GitLab Pages will do.

From that point on, I was on a quest to find a tutorial to help me on my journey in getting up a Digital Ocean server to run my Rails application. Searching Google, resulted in this excellent tutorial by Sophie DeBenedetto. Her tutorial got me very close to getting up and running but I had to deviate a little to get my server working correctly.

First point of deviation was setting up Phusion Passenger and nginx. For some reason the steps in Sophie’s tutorial didn’t work for me. I ended up messing up nginx beyond repair, so I just destroyed my droplet and started again. This time when it came time to setup Passenger and nginx, I went straight to the source at Phusion’s website for help. Their official tutorial actually worked for me.

The next point of deviation from Sophie’s tutorial was that once the app was up and running, I wanted letsencrypt on my nginx server to serve up my app over SSL. For that I found that Digital Ocean had an excellent tutorial. I followed along and now the domain that the app is hosted on is secure.

I used .rbenv-vars to load up environment variables for the Rails app and some other minor things I had to change were the versions of PostgreSQL and Node.js that I installed.

Other than those deviations, I setup Ruby with rbenv — which happens to be my personal preference for setting up Ruby — and was able to follow along Sophie’s tutorial and get my server and app up and running.

So how do I feel now that the app is up and running on its own server? Great! There’s nothing like the sense of accomplish when you finally see the fruits of your labors. But the setup took a couple of nights to get right and it was hard. Although I do feel more confident in my abilities to work with servers, I still have much to learn on the server side.

Now that the “hard” part is done, back to working on the app and getting ready to share it with everyone.

If you’re like me and have found PaaS services a little pricey to host your business, I can’t recommend giving Digital Ocean a shot! Although the learning curve is high and you’ll want to be comfortable in the command-line before you start, the benefits of running your app on a Digital Ocean VPS are good.

Thanks for taking the time to read this article. I'd love to stay in touch and share more tips on programming and design, side projects and working remotely. Sign up and I'll send you my articles straight to your email.

:wave: Hey hey, I'm Michael Lee! I really appreciate you taking the time to read this article.

Be sure to check out my other articles.