0
votes

I have ruby and the gems installed within /home/insane-36/.rvm directory. I installed the passenger gem and created passenger.load and passenger.conf files within apache mod-available and enabled the mod for apache. The content of these files are as;

passenger.load

LoadModule passenger_module /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/ext/apache2/mod_passenger.so

passenger.conf

PassengerRoot /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12 PassengerRuby /home/insane-36/.rvm/wrappers/ruby-1.9.3-p194/ruby

Then, I created a symlink for the application at location /home/insane-36/www/testing to /var/www/testing. I also created a file to enable the site as;

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName testing
    DocumentRoot /var/www/testing/public/   
    <Directory /var/www/testing/public/>
      Options Indexes +ExecCGI FollowSymLinks 
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>

Then enabled the site and restarted the server but it gives me error saying ruby (rack) application could not be started. I kept on searching the internet and found some solutions but none work to me. I think this is permission issue. I dont know what the permission should be set. I guess the files should be made available to the apache user. And tried modifying the permission but instead have the same error. The detailed log is as;

A source file that the application requires, is missing.
It is possible that you didn't upload your application files correctly. Please check whether all your application files are uploaded.
A required library may not installed. Please install all libraries that this application requires.
Further information about the error may have been written to the application's log file. Please check it in order to analyse the problem.
Error message:
cannot load such file -- rubygems/path_support
Exception class:
LoadError
Application root:
/var/www/testing
Backtrace:
#   File    Line    Location
0   /home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems.rb    395 in `paths'
1   /home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems.rb    416 in `path'
2   /home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb  382 in `dirs'
3   /home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb  267 in `_all'
4   /home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb  410 in `each'
5   /home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb  442 in `find'
6   /home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb  442 in `find_by_path'
7   /home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems.rb    206 in `try_activate'
8   /home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb 59  in `rescue in require'
9   /home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb 35  in `require'
10  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/utils.rb  241 in `prepare_app_process'
11  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb   156 in `block in initialize_server'
12  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/utils.rb  572 in `report_app_init_status'
13  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb   154 in `initialize_server'
14  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb    204 in `start_synchronously'
15  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb    180 in `start'
16  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb   129 in `start'
17  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb  253 in `block (2 levels) in spawn_rack_application'
18  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb 132 in `lookup_or_add'
19  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb  246 in `block in spawn_rack_application'
20  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb 82  in `block in synchronize'
21      prelude>    10:in `synchronize'
22  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb 79  in `synchronize'
23  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb  244 in `spawn_rack_application'
24  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb  137 in `spawn_application'
25  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb  275 in `handle_spawn_application'
26  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb    357 in `server_main_loop'
27  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb    206 in `start_synchronously'
28  /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/helper-scripts/passenger-spawn-server   99  in `'

Any help would be appreciated.

2
No I have not used bundler. Infact I used it to install the gem using bundle command. But, now I modified the few things in the application. I changed the ownership of the application to the same user as the rvm user and set the permission of the user directory to 755. Now, I have a different error. It says ; We're sorry, but something went wrong.Sandeep
Your comment got cut off. My advice would be to remove the gems you have installed for this project via gem uninstall ..., and then install Bundler and then use it to install the gems via bundle install --binstubs --path vendor. That will place all the gems in PROJECT_DIR/vendor, so you won't have to change permissions or anything like that. Then see if the error is still occurring. I occassionally get frustrated using Bundler, but it's perfect for this kind of situation.iain
I should add that after that prefix all the commands with bin/ e.g. bin/rails s, it helps to prevent clashes with gems on other projects (along with using RVM).iain
I dont have a clue what you mean by second comment. But, I tried with the first once and created a copy of all the gems in the vendor directory. But, this does not work either. I just dont have the passenger error but I am redirected to page not found 500 error which says, we're sorry but something went wrongSandeep
Ok now, I finally got everything working. It was because I did not precompiled the assets.Sandeep

2 Answers

1
votes

This is how I deployed the application locally.

sudo gem install passenger
sudo apt-get install apache2-dev libapr1-dev libaprutil1-dev
sudo passenger-install-apache2-module

/etc/apache2/mods-available/passenger.load

LoadModule passenger_module /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/ext/apache2/mod_passenger.so

/etc/apache2/mods-available/passenger.conf

PassengerRoot /home/insane-36/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12 
PassengerRuby /home/insane-36/.rvm/wrappers/ruby-1.9.3-p194/ruby

Now, enabled the mod-passenger for apache as;

> sudo a2enmod passenger

Created a rails application inside /home/insane-36/www/

rails new testing -T -D mysql

Created a symlink to the application in the /var/www/ folder as;

ln -s /home/insane-36/www/testing /var/www/testing

Created a file in /etc/apache2/sites-available/testing

<VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName testing
        DocumentRoot /var/www/testing/public/   
    <Directory /var/www/testing/public/>
     Options Indexes +ExecCGI FollowSymLinks 
         Order allow,deny
         Allow from all
    </Directory>
</VirtualHost>

Enabled the site using,

sudo a2ensite testing

Added the ServerName chosen for and Created a file in /etc/apache2/sites-available/testingthe site to the /etc/hosts file;

testing 127.0.0.1

NOTE: Be sure to enable the permission 755 to the current user directory.

chmod 755 /home/insane-36

    bundle exec rake assets:precompile to compile your assets periodically. 

I still have a problem here. I have managed to make the application work. But, everytime I make changes to the application, I need to reload the server. Is there some ways to deal with this so that server automatically tracks the files being changes then reload the server or combine the changes.

Some notes suggested if I added empty file tmp/restart.txt should work for restarting the app and bring the changes but doesnot work for me.

0
votes

Me thinks you need to delete everything rubygem-related in

/home/insane-36/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1