small medium large xlarge

10 Apr 2012, 23:46
Scott Kennedy (1 post)

Being new to deploying Rails apps I’m having some trouble with Chapter 16 as it seems a bit vague and assumes the reader knows how to properly setup/configure Apache. Spending some time Google I feel like I know a bit more though definitely not enough to get this off the ground. Here are my current questions.

1) “The first will be to enable your freshly built module and will involve adding lines such as the following to our Apache configuration.”

LoadModule passenger_module /home/rubys/.rvm/…/ext/apache2/ PassengerRoot /home/rubys/.rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.8 PassengerRuby /home/rubys/.rvm/wrappers/ruby-1.9.3-p0/ruby

Where in the configuration file does this information go? Does it matter?

2) Deploying our Application Locally <VirtualHost *:80> ServerName DocumentRoot /home/rubys/work/depot/public/ <Directory /home/rubys/work/depot/public> AllowOverride all Options -MultiViews Order allow,deny Allow from all </Directory> </VirtualHost>

Again, where does this code go within the configuration file, does it matter? Is the server name something arbitrary, meaning I can pick anything I want so long as I map it in the hosts file? I assume the DocumentRoot is the complete file path to the Rails app so given the location of my rails app would I use the following, ~/projects/depot/public ?

3) What goes in the hosts file? (where matches the ServerName from the Apache config file?)

Very confused by this setup with very vague steps and would appreciate any help which you can provide, even if it’s only a partial answer.

** Note: Everything I find about OSX and Passenger links me to Ben Ruebenstein’s guide which no longer exists due to an error.

12 Apr 2012, 14:50
John Lane (6 posts)

Hi Scott, just working through the same section. In apache you need to add this:

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p0@rails/gems/passenger-3.0.11/ext/apache2/                                                                                              
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p0@rails/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p0@rails/ruby

<VirtualHost *:80>
  DocumentRoot /home/john/awdwr/depot/public/
  <Directory /home/john/awdwr/depot/public>
    AllowOverride all 
    Options -MultiViews
    Order allow,deny
    Allow from all

You should be able to just stick it at the end of your httpd.conf file (I’m on Arch Linux and mine is at /etc/httpd/conf/httpd.conf).

You also need to locate the line @Listen 80@ and insert a new line @NameVirtualHost :80@ before it.

In @/etc/hosts@ (on the machine where you will run your web browser) add a line like this:

Where the IP address is that of your server (if it’s the same then localhost or should work).

You’ll obviously need to change the paths in the above to suit your environment.

I will add that I am using ruby 1.9.3 and rails 3.2.2 and I have had loads of problems getting this to work. The book has errors (e.g. in your @config/database.yml@ you need @mysql2@ as the adapter not @mysql@ as the book states). You may also hit erros about assets not being compiled and so on… I am still working through these issues…

I am also using rvm which somewhat muddies the waters too…

21 Apr 2012, 20:30
Bill Dieter (2 posts)

I think the book is a little vague because there are so many ways to configure Apache. Each Linux distribution has its own opinion, not to mention Mac OS X and Windows.

You can certainly append the lines above to @/etc/apache2/httpd.conf@ (the location of the config file for the default Mac install.) On Ubuntu, the last line in main config file is: ` Include sites-enabled/ ` which causes it to include all the files in the sites-enabled directory, which is in the same directory as the config file. The advantage of this approach is that you can keep all your site files separate from the main file and each other. That way when a system upgrade changes the config file, you do not lose all your site config files, and you can enable or diable individual sites independently.

There is also a separate @mods-enabled@ directory to handle the loading of the module, because if you have multiple sites that use passenger, you only need to load the passenger module once.

You must be logged in to comment