How to deploy a Ruby on Rails app to AWS-EC2 Ubuntu Linux using Apache 2? - ruby-on-rails

We want to configure Apache to work with a Rails app. We want Apache to do load control. We cannot get them to work together. We are using MySQL for the database. If we could please have some type of instruction or tutorial to follow to be able to deploy our application in AWS-EC2, it will be greatly appreciated.
We have a domain and we want to have multiple Rails app running in the same domain. Each rails app seems to want to run in a different port. We do not want to expose port 80/443. Apache is managing the inbound request. My attempts to use the host file has not been successful.

Related

Is one rails server per application?

I have two questions about rails server:
Do I have to start the server from within the application folder?
Is the server I started only for that application?
If they are true, this does not quite make sense to me, since why do I need to start multiple servers?
Or is there some kind of master configuration, so that one server can route to different applications? Is Capistrano for this purpose?
I'm going to assume you're talking about the rails server command, for running a local rails server to test your application, and that you're not talking about setting up a rails application on a remote server. Please mention if that is not the case.
Yes, you must execute rails server from within the root folder of your rails application.
Yes, the server you started is only for that application. It's a self-contained thing.
You should not need to start multiple servers. Even if you have multiple applications, you probably don't need to have more than one running at a time. So, you can shut down the rails server in one application (Ctrl-C) and then cd to your new application, and start a new rails server there with rails server.
If you do need to run two local rails applications at once, you can do so by running them on different ports. So, the first one, you can just execute rails server and it will make your site available at localhost:3000 (because port 3000 is the default port). The next one, you can specify a port other than 3000 - eg. rails server -p 3001 to get a rails app at localhost:3001.
Capistrano is for deploying your applications to a remote server, not for running them locally on your own computer. So, it is not relevant here. What you may be interested in is http://pow.cx/
Again, I've assumed you're talking about running your rails app locally on your own computer. If you're referring to deploying it to the internet on a server, then you can ignore this answer.

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.

AngularJS frontend and Rails backend with AWS in Ubuntu

I would like to discuss about AngularJS and Ruby on Rails working together and deployed in AWS (Amazon Web Services).
So far, I have a development environment with an AngularJS frontend that sends request to a Ruby on Rails API backend. These both are two separate applications (they are in separated git repositories).
The AngularJS app is running in a Node.js server listening on one port, and Rails is running in a Webrick server listening on another port.
Although they work together, AngularJS is not physically integrated in the RoR app.
Now its time to deploy in production environment. For that, I will use an EC2 AWS instance (currently deploying using Elastic Beanstalk). As far as I understand, I can't have the same architecture here.
I would like to know your suggestions this point. Do you see any advantages or disadvantages?
Should I update my development environment, so the AngularJS app is integrated inside the RoR application (and deploy just one application)?
This is something I don't like, because I guess I have to modify many things.
On the other hand, is it possible to run both applications separately, the same way I do in development?
Can I install a node.js and a Unicorn or whichever server manually in production in the same instance?
I finally deployed with two separated applications as described above. The main difference is around the servers. My AngularJS frontend finally runs on an Nginx. And my Rails API is running on a Unicorn.

How to deploy a rails app with no domain name. (trying to create a test server)

Ok so what i'm trying to do is deploy my first rails project. I've asked this question and i think i figured out that you can't configure apache to work using an ip and you have to have a domain name.
The reason i can't use the domain name yet is because i'm recreating a site for someone and they don't want it to be down in between switching the domain from their current site to their new rails site.
I'd like to get my rails app running on a server so I can test it out and then once it's ready, switch the domain name.
How can i setup a server to run a rails project without using the domain name?
If you want to run the rails project locally in development mode, then just run the command rails s from the root of your project.
It is possible to deploy two apps to the same server, or two versions of the same app, I typically use sub-domains for this, website.com and then testing.website.com.
You will just need to have seperate databases and seperate virtualhost files.
You could also try to access the apache machine by it's IP address if it is on the local network.

Deploying Apache Solr

I've been experimenting with Apache SOLR and I'm ready to integrate it with a rails application. However, I'd like to make sure I know how to deploy solr. I currently have the rails application deployed using passenger+nginx. Is it possible to deploy SOLR using nginx as well? If so, how would I do that? Otherwise, what is the preferred method of deployment? Thanks!
Solr needs to run in a Java EE application server. You can use Jetty or Tomcat. Nginx will act as a proxy via AJP or something simliar to forward all RESTless request to Solr. I haven't used my ajp with nginx but I have read about this. Essentially you will have a Java EE application server, Rails server, nginx, passenger and ajp proxy running all at the same time.
You can also setup a proxy pass and there is a tutorial here. Explore different options to see which one is bet for you.

Resources