Can I run LAMP and Rails from the same Apache instance? - ruby-on-rails

We have a RedHat box with Apache2, PHP5 and MySQL 5 for much of our development. Now, we have a Rails client, and we need to set up a Rails app on the same server. Can we install Ruby and the Rails framework with the same Apache, or should we avoid this? Why or Why not? Is it possible to direct subdomains to either PHP or Ruby in the individual V-host definitions?

Yes, you can configure your virtual hosts to Rails, PHP, or anything else with the proper configuration. The details depend largely on how you are connecting to Rails, but generally however you would configure a single purpose Apache server should work for the virtual hosts.

Yeah - Install passenger, then you can configure your sites through your apache conf files. The passenger docs contain everything you'll need to know!

Related

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

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.

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.

Can someone explain to me in simple terms what Passenger is?

I was researching to set up my linux (ubuntu) vps for rails. And almost all of the guides I've read tells me to install passenger. But none of the guides explain what it is (atleast not in simple terms). So I was wondering if someone could explain in simple terms what exactly passenger is.
I'm trying to set up my VPS so I can easily push code to it from git, and deploy my app (Easy as heroku?) Any suggestions?
Your web server (apache/nginx) serves HTTP requests for files, like stylesheets and images. But, it doesn't know how to process programming code. In PHP, for example, you have to enable mod_php to allow PHP to run.
Passenger is to ruby/rails what mod_php is to PHP.
Your web server still serves static files, but has passenger run your ruby code.
Passenger usually works with Apache/nginx.
Passenger does the dynamic things, Apache/nginx serves
static files and helps passenger to communicate with user-agents
mod passenger or phusion passenger is a module to deploy ruby on rails application in nginx or apache . Currently you must be using either web brick or mongrel. using mod passenger you can have the full power of nginx or apache at your disposal,

Configuring Passenger with Ruby 1.9.2 + Rails 3.1.0rc4 and Ruby 1.8.6 + Rails 2.3.11

How can I configure Passenger to run two different projects under these requirements?
First project is Redmine (Rails 2.3.11 and Ruby 1.8.6) and second one is something like a mini-blog (Rails 3.1.0rc4 and Ruby 1.9.2).
OS: Ubuntu Server
Personally, I prefer nginx to Apache, but you can do this with both.
First, the bad news - you cannot do this with a single installation of either Apache or nginx - passenger is compiled against a single specific ruby interpreter that you are using. Now, the good news is that since you have rvm setup, it is trivial to manage multiple ruby interpreters.
You need to have two separate http server (Apache or nginx) installations - one will be the default and answer on port 80, and the other will need to answer on another port (this will not be publicly used). You need to compile passenger for one ruby and http server (Apache or nginx), and another passenger for the other ruby and http server (both http servers can be Apache, both can be nginx, or if you want to make things "interesting", you can have one of each). I highly recommend using ruby 1.9 with your default (port 80) passenger since any new apps you run on the server will be using ruby 1.9+/rails 3+.
Once you have each http server + ruby + passenger setup, you will need to configure your secondary site (running on the not-port-80 web server) as a proxy + reverse proxy from the port 80 http server to the secondary http server (e.g. port 5000).
I have this configuration running for a couple different clients (on different production servers) and do not have any trouble. In one case, we are using passenger standalone servers for the secondary ruby/passenger combination rather than having a full nginx installation - this has proven to be quite stable, but creating functional init scripts that worked as we wanted was a bit fun.

Serving web application without Lighttpd/Apache

As Rails applications default run on port 3000, would it be possible to start the application on port 80? Is it really required to have a fastcgi/mod_proxy enabled web server in front? My users won't be more than three at a time. If so, how would I be able to do so?
Thanks!
WARNING: This is not a general purpose description of how to set up a Ruby on Rails production environment. If you want to host a public Rails website, I highly recommend using Apache with Passenger, which is very easy to install and maintain.
From your description, it sounds like you are working with some kind of internal application to be used within your office or similar. For this particular purpose, hosting the application via Webrick (the built-in web server in Rails) might be a sufficient solution. To do this, start the server with a -p command line argument: ruby script/server -p 80
This obviously requires port 80 to be available (not bound by some other web server). Also, on most operating systems, you will need root privileges to bind to port 80. The security implications of running a web site as root are serious, so you really only want to do this if you know what you are doing, and are absolutely sure that the server is completely shielded from the Internet.
If there isn't some specific reason you're trying to run with mongrel, I would recommend using Phusion Passenger as it is significantly easier to configure and support than mod_proxy+mongrel.
mongrel - http://github.com/fauna/mongrel
thin - http://code.macournoyer.com/thin/

Resources