Our guidance sources shall be today:

Now, when having all interesting source material in hand lets proceed with install

Step 1: Install passenger and various relevant development libraries

zypper addrepo http://download.opensuse.org/repositories/OBS:Server:Unstable/openSUSE_13.2/OBS:Server:Unstable.repo
zypper refresh
zypper install rubygem-passenger
zypper install apache2-devel
zypper install curl-devel
zypper install ruby-devel
zypper install pcre-devel

Step 2: Configure passenger

passenger-install-apache2-module
...

This will compile bunch of stuff and eventually (hopefully give following info)

--------------------------------------------
Almost there!

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/lib64/ruby/gems/2.1.0/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
   
     PassengerRoot /usr/lib64/ruby/gems/2.1.0/gems/passenger-4.0.53
     PassengerDefaultRuby /usr/bin/ruby.ruby2.1
   

After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!

Press ENTER to continue.

--------------------------------------------

Deploying a web application: an example

Suppose you have a web application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:

   
      ServerName www.yourhost.com
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public
      
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
         # Uncomment this if you're on Apache >= 2.4:
         #Require all granted
      
   

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

  /usr/lib64/ruby/gems/2.1.0/gems/passenger-4.0.53/doc/Users guide Apache.html
  https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
https://www.phusionpassenger.com

Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.

Lets ignore for a while instructions about apache2 configuration, and see what got so far.

Step 3: Try if apache2 still starts

# need to create this dir; it's seemingly not autocreated
mkdir /run/passenger
service apache2 restart
service apache2 status
less /var/log/apache2/error_log

Okey, at this point error_log contains various errors from passenger but apache2 itself is still running (and luckily so, since otherwise writing this blog post would become challenging since we are doing changes in server hosting this blog).

Step 4: Setup new virtual host config

emacs /etc/apache2/vhosts.d/host.kari.dy.fi.conf

/etc/apache2/vhosts.d/host.kari.dy.fi.conf


  ServerName host.kari.dy.fi
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /home/www/virtual/host.kari.dy.fi/public

  # if not specified, the global error log is used
  ErrorLog /var/log/apache2/host.kari.dy.fi-error_log
  CustomLog /var/log/apache2/host.kari.dy.fi-access_log combined

  
    # This relaxes Apache security settings.
    AllowOverride all
    # MultiViews must be turned off.
    Options -MultiViews
    # Uncomment this if you're on Apache >= 2.4:
    Require all granted
  

Step 5: Setup virtual server

cd /home/www/virtual
git clone https://github.com/kikonen/host host.kari.dy.fi
cd host.kari.dy.fi
bundle

okey… lets cross fingers and restart apache2 yet’another time.

Step 6: Try if apache2 still starts

service apache2 restart
service apache2 status
less /var/log/apache2/error_log
ls -l /var/log/apache2/host.kari.dy.fi-*

If we are lucky, then passenger is starting up, and new virtual host is also configured up.

Step 7: Lets try it out in web browser

http://host.kari.dy.fi/

Okey, not good, getting in web browser

cannot load such file -- phusion_passenger (LoadError)
  /usr/lib64/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/lib64/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/lib64/passenger/4.0.53//helper-scripts/rack-preloader.rb:73:in `init_passenger'
  /usr/lib64/passenger/4.0.53//helper-scripts/rack-preloader.rb:157:in `'
  /usr/lib64/passenger/4.0.53//helper-scripts/rack-preloader.rb:29:in `'
  /usr/lib64/passenger/4.0.53//helper-scripts/rack-preloader.rb:28:in `
'

Lets start troubleshooting that. Even if we are getting this error, it indicates already that we are getting somewhere, since error is pointing into Passenger, so at least something is working.

Searching for help,

  • http://stackoverflow.com/questions/27058601/passenger-load-error-cannot-load-such-file-phusion-passenger-loaderror
  • http://stackoverflow.com/questions/27058601/passenger-load-error-cannot-load-such-file-phusion-passenger-loaderror

Step 8: Fiddle with config files
This might be totally redundant, but lets’ try it anyway.

/etc/apache2/http.conf.local;


  PassengerRoot /usr/lib64/ruby/gems/2.1.0/gems/passenger-4.0.53
  PassengerDefaultRuby /usr/bin/ruby.ruby2.1

Step 9: What about running passenger manually?

# start passenger manually
passenger start
# That triggers "Compiling Phusion Passenger..."
# => sounds promising
# => also irrelevant since that is just passenger standalone, so waste of time

service apache2 restart

In the end, it appears that trouble came from the user for which gems were installed. I.e. ”passenger” gem needs to be installed for correct ruby version in the environment of the user used to run rails server application in virtual host. If not so, passenger will just promptly fail.

TODO: Need to cleanup gem setup logic, and perhaps see if it’s possible setup passenger to run using rvm, so that it wouldn’t depend from the globally installed ruby version. I.e. I would rather use ruby version, which can be updated without dependency into one deployed via Linux package manager.

After fixing gem issue, rails seems to boot, but fails with error page. However, this is good thing, since some clear progress is done in this journey.

However, next problem is easy familiar error; just need to setup secret_key for production

*** Exception RuntimeError in Rack application object (Missing `secret_token` and `secret_key_base` for 'prod\
   uction' environment, set these values in `config/secrets.yml`)

…. and after fixing that small mistake, our rails server popups into aliveness. Neat!

Mission completed
Host Rails Server