How do I get Ruby on Rails 5.2 to work with Nginx?

December 30, 2018 1.1k views
MySQL Ruby on Rails Ubuntu 18.04 Nginx

I have tried basically everything to get my website Duelingpets to work with the new version of rails but each time it is continously failing. I tried to get it working on Apache but it kept displaying index of / instead. I tried to get it working with nginx on its own but it only displayed the nginx welcome screen instead of ruby. I have tried nginx with passenger and that was equally a failure as well.

What am I doing wrong and why does this continue to not work?
I have followed all the digital ocean tutorial steps but none of them seem to actually fix things. I have yet to get an answer or solutions to this problem and I been creating several different droplets just to find out how to get it to work. Why is it that Rails 5.2 plays perfectly well with my linux laptop but if I try to get it working with an ubuntu server on digital ocean it completely fails? Why????????

I am kind of at a loss as to why this is happening.
Can someone please help me to solve this issue as I want to have my site up and running on the newer version without having to rely on my older version.

Here are the guides I used for the work:
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-18-04

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04

https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04

https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04

https://stackoverflow.com/questions/53894256/how-do-i-get-my-website-to-display-welcome-to-rails-instead-of-index-of-in-rub

3 Answers

It reads like you’ve had many stabs at this and are fed up with how things are going. But some things require a closer look to get them ironed out. Why don’t you set things up per the tutorial with your Rails app and I’ll take a look at whatever issue you’re still having.

Cheers

Hi,
You need to edit the rails.service file to set the ‘default’ site
/etc/systemd/system/rails.service

[Unit]
Description=ExampleApp <– change this to Duelingpets
Requires=network.target

[Service]
Type=simple
User=rails
Group=rails
WorkingDirectory=/home/rails/example/ <– change this to the new path
ExecStart=/bin/bash -lc 'bundle exec puma’
TimeoutSec=30s
RestartSec=30s
Restart=always

[Install]
WantedBy=multi-user.target

Have another answer? Share your knowledge.