Using Phusion/mod_rails - ruby

I've been looking into using mod_rails (Phusion), but I just wanted to verify this: Once it's installed, I can still serve regular, non-rails apps from the same server without making any changes. Is this correct?

It is correct. I'm using Passenger in a project with other PHP projects and it works fine (even some PHP files in your public folder).
You can also set the passenger to start standalone (passenger start -d in your rails root folder) and use the mod_proxy and mod_rewrite from Apache to handle it (redirecting the rails requests to the rails app).

Yes, you can still serve non-rails applications using the same server.
mod_rails automatically detects which DocumentRoots are Rails applications by looking for public, for example.

Related

What needs to be done when moving a ruby on rails (RoR) app to a different directory?

I generated the default RoR application with the rails new <project_name> command, and everything seemed to go fine. Later I decided I wanted to relocate my rails projects in a different directory (something other than my home directory), so I moved the RoR project to /opt/rails/<project_name> and I created a symlink in my web root pointing to /opt/rails/<project_name>/public, and the page loads fine, but some of the assets aren't loading on the Welcome aboard page, i.e. the rails.png And when I go to click on the About your application's environment link I get a 404 error. If I had to take a guess as to why I'm getting these errors it would have to be that I moved the rails app simple_cms from /home/user/www/rails/simple_cms to /opt/rails/simple_cms Is there a command I need to issue in the project root of simple_cms to get things fully working?
Update
I'm using Apache 2 as the web server on a CentOS 5.9 box.
If you are using rails s to launch your app, then there is no need to create symlinks. The web server (could be WEBrick, or Thin) will serve the application from the app root.
If you are using Apache or Nginx, again there is no need to create symlinks, but you need to let Apache/Nginx know the new location. For example, in a Nginx+Passenger setup, you would need to set passenger_app_root to the new location.
Provide more details in your question, or consult the documentation for your setup.

Heroku not serving static/public folder with Unicorn and Rails 2.3 app

I have been able to get Unicorn to start up properly with my Rails 2.3 app on Heroku's Cedar Stack, however, it is not serving the static assets correctly from the public folder. I have tried placing this line in our config/environments/production.rb:
config.serve_static_assets = true
But then our app fails to load properly. Without it, the app boots fine, just doesn't serve the static files. Is that line of code not compatible with Rails 2.3?
One note for people with the same sort of config, make sure to create a config.ru in your app root.
Just a hunch, but check out the injected-plugins section of the Heroku Ruby support docs. It talks about a gem that may solve this issue by injecting this configuration after the app has been initialized.

How can I run a Ramaze app on Apache or Litespeed in a ruby enabled environment?

Also in Cpanel, I have Rubygems and Rails icons to go to those pages.
I can see tutorials for how to setup Sinatra on Apache, but they don't work for Ramaze and I'm using Litespeed server.
For another question, how can I run a Ramaze app on Apache in a ruby enabled environment? Maybe Apache and Litespeed are dual-installed.
I added https://gist.github.com/2cf310f39b13f5d6f3b4 as my .htaccess file and it did not work for http://compesh.uk.to Cpanel says I also have Apache but online says Litespeed.
You need something more than just apache for a ruby app (phusion passenger for example). Ramaze is a rake based app gem so you should have a look to this side...
First google result for "deploy ramaze" : http://www.codeotaku.com/blog/2009-10/ramaze-and-rack
Good luck ! ;-)

Can a Sinatra or Rack application find out if it is running with Apache or Thin?

I am trying to do some silly automatic configuration of a Sinatra application which would allow to use it from different sub URI depending whether it is run with Apache and Passenger, or with Thin web server.
So my question is: is it possible to find out from inside a Sinatra application what web server runs it?
You can't (as far as I know) see if it's running on Apache, but you can check if it's running on Passenger:
if defined?(PhusionPassenger)
# We are running Passenger!
end
You should be able to do the same for Thin:
if defined?(Thin)
# We are running Thin!
end

Integrating Ruby on Windows WAMP server so I can run Ruby and PHP at same time?

I've been searching on this but haven't found anything decisive so far.. I already have a windows WAMP server up and running and am using it for my PHP apps, I want to be able to run some small ruby scripts (to interact with a library that is not available in PHP), I don't even need Rails at this point, I just want to run ruby scripts and be able to run them from within a web browser type environment (like PHP) but I can't figure out how to do this since the "instant rails" takes the same resources of php and apache so it can't run at the same time unless I change the port but I'd rather just make it so it runs off the same apache as my PHP apps ( I don't even need a database at this point as thats all handled in my php apps).. any advice is appreciated
Seeing that you have accepted the answer from your other question: you won't be able to run a ruby TCP server on port X and Apache on the same port.
On the other hand if you decide to use Rails: Install InstantRails but don't start it. Copy the portion of Apache config (in InstantRails directory) that binds rails to Apache and edit it to handle everything under (for eample) /rails then paste it into your Apache config that runs PHP. You may have to fiddle with paths (PATH variable). This way you'll have Apache running on port X, all *.php will go to your PHP interpreter and everything under (for example) /rails will go to Rails/Ruby

Resources