Topic: hostmonster

Hi Guys,
Does anyone in here run their rails app on hostmonster? if so how did you get it up and running? I've try to follow the instruction on their help section and still couldnt get it up and running. Stuck on the Passenger page error, with this error

Error message:
No such file or directory - config/environment.rb

can anyone help me out with this?
Thanks

-Michael

Last edited by urdabum (2012-07-14 19:10:19)

-Michael

Re: hostmonster

Hello, I run many rails apps in hostmonster with fastCGI so I can give some instructions.

1) First of all you need to create your new addon domain from cPanel. This will create a folder in the public_html folder which you need to change it, you should link it to your public folder of your rails app. To do this you need ssh access, so you login with ssh and you type:
cd ~/public_html/
rm -r folder_of_your_addon_domain
ln -s $HOME/rails/name_of_your_app/public $HOME/public_html/folder_of_your_addon_domain

Also a tip when your rails app is up and running with fastCGI, if you are in production mode, the changes you made won't happen immediately, you need to restart your app, so to do this you need to login with ssh access and type in killall dispatch.fcgi

2) Second you need the dispatchers. To get them you need to type rails test_app_just_to_get_the_dispatchers -D with ssh as far as I remembered (the dispatchers will be in the public directory of your new test rails app). This will give you 4 files (dispatch.cgi, dispatch.fcgi, dispatch.rb, .htaccess). Copy all of them and paste them into the public folder of your normal rails app. IMPORTANT: Change to 755 the privileges of this file otherwise it won't work! I have forgotten this one many times in the past and I couldn't figured out why my rails app isn't running. I am changing them with my FTP program (filezilla), right click the file and it is the last option (you can do it also with ssh).

3) Third, last and most important step for hostmonster specific, open your config/environment.rb file of your rails app and write on top of all, this one:
ENV['GEM_PATH'] = '/home/the_name_of_your_login_in_ssh/ruby/gems:/usr/lib64/ruby/gems/1.8', I also put this RAILS_ENV = 'production' to run it in production mode and I comment the rails version like this #RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION, for some reason I remember it didn't worked when it was uncomment.

This is how it looks like my .htaccess file:

AddHandler fcgid-script .fcgi
AddHandler cgi-script .cgi
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks +ExecCGI
Options +SymLinksIfOwnerMatch +ExecCGI
RewriteEngine On

RewriteCond %{HTTP_HOST} ^your-domain-name.com [NC]
RewriteRule ^(.*)$ http://www.your-domain-name.com/$1 [L,R=301]
This two lines in italic, isn't neccesary, I am adding them for SEO reason (redirecting the non-www domain version to www)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 /500.html
#ErrorDocument 500 "

There are many guides on the internet for fastCGI and how to deploy a rails app, this one is for hostmonster and is working date: 4 April 2010, the last step is important to set the gem folder of your rails app and is hostmonster specific. The other steps are for every fastCGI deploy on shared hosting.

Hope this helped you (and also I hope I didn't forget anything!)

Re: hostmonster

When you create your first rails app, the directories are laid out for you. ... are important – it lets rails applications “find their parts” easily, .... You got it — Ruby needs to be installed to run the various files ...

Re: hostmonster

The FastCGI Extension for Internet Information Services (IIS) 6.0 and 5.1 enables popular application frameworks (such as PHP) to be hosted on the IIS web ...

Re: hostmonster

Thank You!  I was missing the GEM path in environment.rb. 
This marks the end of 12 hours of frustration!  Celebration!!
cheers,
Don

Re: hostmonster

Is there anyway to run Ruby on Rails and Apache on Hostmonster without buying a dedicated IP so as to use Port 3000?

Re: hostmonster

Even thought I only have one rail app on the host do I still need to do the addon_domain?

So I followed your instruction and still having the same error.

Step 1:

ln -s $HOME/rails_app/my_app/public $HOME/pubic_html/my_app

Step 2:

rails dispatch_test_app -D
cd rails_app/dispatch_test_app/public
chmod 755 dispatch.cgi
chmod 755 dispatch.fcgi
chmod 755 dispatch.rb
chmod 755 .htaccess

cp /rails_app/dispatch_test_app/public/dispatch.cgi /rails_app/my_app/public
cp /rails_app/dispatch_test_app/public/dispatch.fcgi /rails_app/my_app/public
cp /rails_app/dispatch_test_app/public/dispatch.rb /rails_app/my_app/public
cp /rails_app/dispatch_test_app/public/.htacess /rails_app/my_app/public

Step 3:

vim my_app/config/enviroment.rb

I then write :

ENV['GEM_PATH'] = '/home/usr_account/ruby/gems:/usr/lib64/ruby/gems/1.8'

RAILS_ENV = 'production'

on top or everything as you stated, and commented out

#RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION

Step 4:

vim my_app/public/.htaccess

and then copy and paste what you put down

AddHandler fcgid-script .fcgi
AddHandler cgi-script .cgi
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks +ExecCGI
Options +SymLinksIfOwnerMatch +ExecCGI
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 /500.html
#ErrorDocument 500 "

Last edited by urdabum (2012-07-14 19:56:45)

-Michael

Re: hostmonster

then when I do
killall dispatch.fcgi
i get this
dispatch.fcgi: no process killed

After all that I still have the same error as before.
stuck on the passenger page when I try to go to my main domain site. www.my_app.com

Ruby on Rails application could not be started
These are the possible causes:
There may be a syntax error in the application's code. Please check for such errors and fix them.
A required library may not installed. Please install all libraries that this application requires.
The application may not be properly configured. Please check whether all configuration files are written correctly, fix any incorrect configurations, and restart this application.
A service that the application relies on (such as the database server or the Ferret search engine server) may not have been started. Please start that service.
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:
No such file or directory - config/environment.rb
Exception class:-
Errno::ENOENT


Can you let me know if I did something wrong or missing something?

Thanks

-Michael

Re: hostmonster

Hey Michael,

I'm in the middle of trying to get my Rails app working on Hostmonster.
I'm stuck with Rails 2 server. I updated to Rails 3 but no one at Hostmonster can tell me how to run that version instead of rails 2.

As for your situation...

I'm guessing you uploaded your files to the wrong place.
The files go into the ~/rails_apps/YOUR_APP_NAME folder.

Did you upload them to ~/public_html/YOUR_APP_NAME ?
-or-
Did you upload them to ~/rails_apps/YOUR_APP_NAME/public?

Also, I only uploaded the app directory & public directory & the files for the config directory.
Your error looks simple, as in, the environment.rb is not in the config folder  <--- at least not where the server thinks it should be.

Last edited by IronMike (2012-07-15 00:12:55)

Re: hostmonster

I'm in the middle of trying to get my Rails app working on Hostmonster.
I'm stuck with Rails 2 server. I updated to Rails 3 but no one at Hostmonster can tell me how to run that version instead of rails 2.