Deploying rails app on Digital Ocean with passenger and NGINX - ruby-on-rails

This is the very first app I am deploying so I'm not 100% familiar with the whole process.
Right now, all my code for the app is on my server, and if i run rails s and bind it to my droplet ip, it shows up perfectly(i.e. if i go to myipaddress:3000).
But, if I just go to myipaddress on my browser, i just get a 500 error page.
I am confused about the whole process, do i have to have my rails s running the whole time when deployed and running on the server?
If not what am I doing wrong and how can i fix it so that it just shows up when I go to my droplet ipaddress?
My nginx.conf file has its server name pointed to my droplet ip and its root pointed at my apps root folder.
Also, im not getting any errors logged into my nginx/log/error.log file

First of all you don't need to start server with rails s.
You just need to install passenger and nginx for start application with installation of ruby on rails.
And if you just want to check your app is running or not then start server with rails s into digitalocean and try to open it with browser with `ip:3000' then it will work.
From this Ref. link you can start with passenger and nginx.
Let me know if you need more help.

Related

I can not open the url of the site deployed with dokku

Hello everybody) I started learning dokku. Going through the tutorial from the documentation for the Heroku Ruby on Rails "Getting Started" app I can't go to url generated by dokku in the browser. I am only using my local machine while learning and doing git push to localhost. This command works without errors, the container works, I get the url to the site, but I cannot open it in the browser. The same problem appears with another project, when I try to deploy a python django project, this is just a project skeleton created by django, without my code. It must show a welcome page and I want to see it when the site is running on dokku but I cannot go to the url. I tried to use dokku domains and dokku proxy but couldn't solve the problem. Please help me figure out how to fix this. I'm new to dokku, docker, nginx and deployment so the problem can be trivial. I'm also want to know on which ip, port dokku runs the sites and on which ip do I need to run the wsgi server inside the container?

How to run rails applications on digitalocean using "rails s" (make it a development environment)

My issue is that I created a droplet to develop Rails apps in digitalocean .
I used the one-click rails droplet. And now I want to create more rails apps than the default rails app in this droplet.
The issue here is that it comes installed with nginx/unicorn .. And they're always on with path of default rails project in their config files.
Now let's assume I created another rails app(file) and I want to run it using "rails s" instead of default rails app that is created by the droplet. How can I do it?
Note: I don't want to change the file path in configs each time I decide to try another app
PS: I tried stopping the service of unicorn/nginx one at a time and both of them in the same time to use "rail s" to run the app .. But it didn't work .. Web pages were not loading
I know it might be a question of a rookie. But I'm kinda new to these stuff and I'd appreciate it if anyone could help me.
If you run it with rails s on the server, chances are it will be running with Puma, or if you're on an older version of Rails, Webrick. Unicorn is not involved in that case because Rails is using its own default web server. If you see that 'rails s' is not running in the right environment, it may be because RAILS_ENV is being set in your shell profile. You can override that by doing:
RAILS_ENV=development rails s
To launch your console.
That being said, rails s runs on localhost:3000 by default - and in the case you described it would be running on DigitalOcean's localhost - not yours. In order to get to it from your local machine, you would need to set up some sort of reverse proxy to allow connections to DO to get served from localhost. This is what nginx is doing for you - it's facilitating a reverse proxy.
If you want do use your DO server as a development machine for a second rails app you have, you're going to have to create that new rails app on the server, then create the reverse proxy settings in nginx to direct to it, then finally create the unicorn settings to serve it. This is an uncommon way of developing though. I recommend using your local machine to develop, and setting up Capistrano or some other deploy tool to deploy it to DO instead. You'd still need to add the settings in nginx/unicorn for the second app, but it will save you headache down the road.

Setting up Rails on Hostmonster

I'm able to run rails s through ssh successfully and see the app start up just as it does on my own machine but I'm unable to access the app from the web. The app is directly under the home folder and I have a symbolic link pointing from public_html to the public folder of my rails app, just as this tutorial explains. I even tried setting up a subdomain and every other step in the tutorial to no avail. Any help would be highly appreciated.
You need an application server like Phusion Passenger, Unicorn or puma to run a Ruby app in a production environment. Typically, you'll integrate the application server into a web server's (Apache, nginx) environment.
I don't know about your hoster, but if you have root access, then you can probably use any of these application servers.
The built-in server you start by running rails server is only meant for testing purposes on your local machine. It has not been made with security, performance, stability or any other production-environment criteria in mind.

How do i make nginx and passenger restart automatically after a deploy

I currently have a rails app deployed on a virtual private server.
I use Capistrano, Nginx and passenger to run my rails app on the server.
For some reason I can never get the updated code to display on the site after i have done a cap deploy:update.
The deploy happens fine and the code is even seen on the live server via Vim but if I navigate to the live site it won't display.
My current workaround is rebooting the server, starting nginx and passenger after the server boots back up.
my concern is if someone is logged on to the site when i deploy and restart, it will knock them off the site.
Does anyone have any ideas
If you run touch tmp/restart.txt from your rails root directory, passenger will restart the app. You shouldn't have to restart nginx. After the timestamp of the restart.txt file changes, Passenger will restart for the next request. If your app takes a while to boot, you may want to force this by making a request immediately after touching the file.
You don't need to worry about kicking someone off the site, it won't restart the server if there is a request in process.
If you are still facing the problem you can use Monit gem, in capstraino it works really well.

how to deploy ruby on rails application in xampp in windows xp?

I'm very new to Ruby environment ..
I want to run my Ruby on rails Application in apache in xampp on windows xp rather than WeBrick server which is in-built for ruby on rails...
I tried it by adding Virtual host in apache- http.conf file
When i run my application i'm able to see "Welcome Abroad"....
But when i click on "About your application’s environment"
it was showing error like the following
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
9/9/2011 10:47:31 AM
Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
To deploy your app with apache you need to use phusion passenger http://www.modrails.com
There are plenty of how-to's around the web and the documentation is good enough to get the service running.
This means your Ruby on Rails server is NOT running.
You need to run your server first.
I made a batch file, start-server.bat which contains
d:
cd "D:\Ruby\Web\rails1"
"C:\RailsInstaller\Ruby1.9.3\bin\ruby.exe" script\rails server
then check the PORT number of the server that is running,
So since the port on the screenshot says 10524, you can run it on
http://localhost:10524/

Resources