Installing Ruby Apps on CPanel Servers

I have a CPanel server - uses Apache 2.2 for serving up web pages. Note: I got cpanel VPS after a year and a half of installing/running 3 colocated servers at Hurricane Electric. That required a lot of time on maintenance, learning, setting up remote access, and finally outages (joys of a shared rack). After 18 months, got wise and got a VPS at SolarVPS - they provided a mostly-managed service. No more over-nights in the datacenter (wife was elated). Also, my 3 servers were complete overkill for a few websites. Its a great timesaver and others keep the hardware happy 24x7x365.25. After learning the basics of installing a securing a web server/email/etc the time was needed for continued learning. Thanks Cpanel..

Getting a Ruby App served by Apache

I installed Nesta and its running well - took a few hours as its my first venture to Ruby land. The challenge was "how do I get Apache to serve from server:port and not a directory?

Answer: mod_proxy

cronjob for running the app

# uplatecoding..
51 * * * * netstat -an | egrep 9393.*LISTEN 1>/dev/null || { cd $HOME/apps/ruby/uplatecoding.com/ && nohup shotgun config.ru & }

test out app - access localhost:9393 via ssh tunnel:

Home -> ssh to example.com and browse the Nesta instance running on the server at localhost:9393

  • ssh -l -p -N -L 2000:localhost:9393 example.com
  • point browser at http://localhost:2000

Add DNS zone in cpanel

Look in the menu - you'll need to have just the DNS zone (unless your DNS is somewhere else).

use for apache config

compile mod-proxy or apxs install it Add to cpanel at ApacheConfiguration -> Includes Editor -> Pre Virtual Host Includes (added to file /etc/httpd/conf/includes/pre_virtualhost_2.conf ) Not sure of the public_html is needed yet - still testing it out..

# uplatecoding Sinatra App
<VirtualHost 1.2.3.4:80>
    ServerName uplatecoding.com
    ServerAlias www.uplatecoding.com
    ProxyPass / http://localhost:9393/
    DocumentRoot /home/someuser/public_html
    <Directory "/">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Published on in