My rails application is running on http://128.199.95.219:3000/ 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 (https://www.digitalocean.com/community/tutorials/how-to-point-to-digitalocean-nameservers-from-common-domain-registrars) 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/unicorn.pid 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!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Try the following link , it sets up everything for you in DO , simple and elegant https://hatchbox.io/?via=chun-yat
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;
server_name yourdomain.com;
location / {
proxy_pass http://127.0.0.1:3000;
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:
screen
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.