views:

63

answers:

1

I have been learning Ruby lately, and I want to upload a test web application to my server. But I can't figure out how to get it to run on my shared hosting.

My Hosting Details

  • Shared Hosting with JustHost (see here for list of features)
  • OS: Linux
  • Apache: 2.2.11
  • cPanel: 11.25.0-STABLE
  • No SSH access.
  • Can install Ruby Gems.
  • Can't install Apache modules.
  • Can "Manage Ruby on Rails Applications" through cPanel.
  • Mongrel gem is installed.

I built the following simple HelloWorld Ruby Rack app using Sinatra:

#!/usr/bin/ruby ruby
require 'rubygems'
require 'sinatra'
get '/hi' do
  "Hello World!"
end

I just can can't figure out how to "start" the application. Do I need to tell Mongrel (or maybe Apache) that the application exists somehow? How do I start this app running? I am happy to provide more info if needed.

+1  A: 

Hi, firstly you have to start your application manualy or by script when the server is starting. Just do something like ruby hi.rb (as described on sinatra webpage it runs appication on the port 4567). Then you have two options. 1) You can access this application directly as: http://yourserver:4567/ or 2) you can use apache as a proxy.

If you want use apache as a proxy you have to use virtualhost servers. for example:

NameVirtualHost hi.server:80
<VirtualHost hi.server:80>
    Servername hi.server
    RewriteEngine On
    <Proxy balancer://hi>
        BalancerMember http://127.0.0.1:4567
    </Proxy>
    ProxyPass / balancer://hi/
    ProxyPassReverse / balancer://hi/
</VirtualHost>

And if you have ie multiple cores you can run hi.rb more then once (each time on diferent port) and you just add new BalancerMember. You can also switch on apache cache using directive: CacheEnable mem /

pejuko
When you say "do something like ruby hi.rb", where do I do this? I don't have SSH access yet, so should I get that?
TandemAdam
Yes, this solution expects that you have access to the server and can run applications and can edit apache config file. If you can't edit apache config files but you can execute your own servers than you can edit .htacces where you put just ProxyPass and ProxyPassReverse and as params you give it / http://127.0.0.1/4567. And if you can't run applications you can try to run it throu cgi resp. fcgi. check out this: http://www.bluehostforums.com/showthread.php?p=76911
pejuko