How do I deploy my rails application?

My rails application is running on how do I point my domain to this port? What is the best way to deploy my rails app?

First, I’ve finished pointing my domain name to DigitalOcean by following this tutorial.

Afterward, I setup a new host name in DigitalOcean by following this ( tutorial.

Now, I’m trying to reconfigure my server with between rails, ngnix, and unicorn by following this tutorial which I am running into problems.

I have reconfigured everything according to the tutorial but the problem I am running into now is starting unicorn. I follow the tutorial to the section called “Create Unicorn Init Script” however when I run sudo service unicorn_appname start, I get this error

/usr/local/rvm/gems/ruby-2.2.1/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:88:in `block in reload': directory for pid=/home/rails/shared/pids/ not writable (ArgumentError)```

I am not sure if this is the tutorial I should follow. Or is there an easier and better way for me to point my domain name to my rails app running in DigitalOcean. Reconfiguring ngnix to take incoming request to port 3000? I really don't know much about unicorn and ngnix. But I'll be happy to learn the right way to do this.

Anyways, please help!

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Try the following link , it sets up everything for you in DO , simple and elegant

While unicorn will help manage your app you can also do a more simple deply using screen and nginx. Using this method your app will not automatically restart if it were to crash.

To do this, first install screen

sudo apt-get update
sudo apt-get install screen

Then adjust your /etc/nginx/sites-enabled/default file to read:

server {
    listen 80;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

Then create a new screen session:


Then run your application. Once it is running, you can detach your shell by pressing Ctrl-a and then d

You can re-attach to your screen session using screen -r

Now just restart nginx to have your proxy setup take effect:

service nginx restart

This will work fairly well for smaller scale sites but unicorn does provide a better method for production applications.