andrnimm
By:
andrnimm

Running Rails app under Apache

July 27, 2017 248 views
Apache Ruby on Rails Ubuntu 16.04

Sorry for the newbie question:

A previous developer on my project had a Rails app up and running in a droplet. I'm not a Rails developer, but I wanted to keep the app available while installing WordPress alongside the Rails app, in the same droplet. Unfortunately I didn't backup before starting.

I installed Apache and Passenger, assigning a virtual host for the Rails app at port 3000. It won't load - the environment is not properly configured under my username.

Here is the error message presented by Passenger:

<^>It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:

bundle install
If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following:

Is this app supposed to be run as the root user?
Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use.
-------- The exception is as follows: -------

Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound)
<^>

I can't run bundle install - I get Could not locate Gemfile or .bundle/ directory

I'd like to either recreate the proper environment for this app, or remove apache and revert the droplet to being a simple Rails server.

1 Answer

Hope still helps. I am new here.

Bundle is a gem. In order to run a Ruby on Rails app, you need to instal rubies, also called gems. There are two famous gem managers: rvm and rbenv. I use rvm in order to have multiple rails app running, but you can simple install one ruby and work with it (if your plan is to have one app).

There is at least 3 ways to install rvm. If you are planning to work with several apps, then it would depend on what linux is running in your server.

Ubuntu has a special library you can see at ubuntu_rvm, which installs rvm under /etc/share/rvm and I love it. It saves me a lot of time because every user you add to rvm group can have its own gemfile (combo of ruby and specific gems like bundler and rails).

If you have centos or other, then you will need to find rvm for multiple users in rvm page.

So, using rails is like having a road to a specific car, being the car your website. You can run one app in one ruby version with its own gems, and in the next directory of the /var/www or public_html you can have another app with its own gems. But you need the gems, the pavement for the road.

To learn rails you take a look at the tutorials they produce.

But maybe the best teach book I have seen on rails is Hartl´s, learn to do your own twitter and then design it properly (a joke you will understand if you see his design).

When you want to speed up your development, take a look at Rails Composer.

When you are ready to deploy. You can choose many gems, but I know for experience, because I learn in those books and sites, that you will always appreciate best directions you can have, so, choose passenger and let them help you to deploy rails apps to your server. They tutorials are the best I have seen.

Have another answer? Share your knowledge.