Installing mod_rails and Rails 3.0.9 on a cPanel machine

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Since we've had some customers who are willing to forgo using the cPanel environment and would like mod_rails and Rails 3 prior to our official support planned for cPanel 11.34, I did take the time to create a guide on how to accomplish installing both onto a cPanel machine:

Installing mod_rails and Rails 3.0.9 on a cPanel machine - cPanel & WHM Admin Blog

Please use this at your own risk with the understanding that cPanel cannot support using this guide in any manner, including tickets being sent into technical support with questions on the instructions.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
I had a customer ask a question elsewhere about whether users can create applications without the root user being required to do so. This is possible to accomplish if the user has jailed shell access with these steps:

1. SSH into machine as jailed shell user

Code:
In all instances, usermame will be the cPanel username for the jailed shell user. domain.com would be the domain name for the account.

2. Create application

Code:
rails new /home/username/hello
cd /home/username/hello
rails generate scaffold person name:string password:string email:string age:integer
rake db:create:all
rake db:migrate
3. Copy database to production

Code:
cd /home/username/hello/db
cp development.sqlite3 production.sqlite3
4. Symlink public directory

Code:
ln -s /home/username/hello/public /home/username/public_html/hello
5. Add rewrite to directory to .htaccess

Code:
echo "RailsBaseURI /hello" >> /home/username/hello/public/.htaccess
6. Create restart file since user cannot restart Apache

Code:
cd /home/username/hello/tmp
touch restart.txt
Enjoy!
 

Andylam

Registered
Aug 1, 2011
2
0
51
Thanks Tristan,

Another question is how do you start and stop multiple instances of the ruby apps on different ports on the same user account?


Since we've had some customers who are willing to forgo using the cPanel environment and would like mod_rails and Rails 3 prior to our official support planned for cPanel 11.34, I did take the time to create a guide on how to accomplish installing both onto a cPanel machine:

Installing mod_rails and Rails 3.0.9 on a cPanel machine - cPanel & WHM Admin Blog

Please use this at your own risk with the understanding that cPanel cannot support using this guide in any manner, including tickets being sent into technical support with questions on the instructions.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
The apps will not run on different ports under mod_rails, since mod_rails runs on port 80 due to being an Apache module. Are you asking how you basically start and stop apps on the account period under this setup?

If you want to see an example of how the processes look under mod_rails (passenger) for an account, here are what you'd see:

[email protected] [/tmp/passenger.1.0.20078/generation-0]# ps aux | grep tristan
tristan 11758 0.7 1.6 92996 34080 ? S 17:11 0:00 Passenger ApplicationSpawner: /home/tristan/hello
tristan 11760 0.0 2.3 132180 49836 ? S 17:11 0:00 Rails: /home/tristan/hello
This is an example of the tristanwallace.com/hello/people application at /home/tristan/hello location on my machine.

Here's a process tree of the processes running forked from httpd:

Code:
[email protected] [/]# pstree -npu
init(1)-+-ruby(11760,tristan)
        |-ruby(14180,danielle)
        |-httpd(20078)-+-leechprotect(20088)
        |              |-httpd(20094)
        |              |-PassengerWatchd(20095)-+-{PassengerWatchd}(20097)
        |              |                        |-PassengerHelper(20098)-+-ruby(20100)
        |              |                        |                        |-{PassengerHelper}(20101)
        |              |                        |                        |-{PassengerHelper}(20102)
        |              |                        |                        `-{PassengerHelper}(20106)
        |              |                        |-PassengerLoggin(20104,nobody)---{PassengerLoggin}(20107)
        |              |                        |-{PassengerWatchd}(20108)
        |              |                        `-{PassengerWatchd}(20109)
I did want to mention that I've found you cannot run EasyApache with this module added without it failing to build. The preferred option at this point would be to use .htaccess files to add the RailsBaseURI rather than includes, then to temporarily comment out the 3 lines added to httpd.conf prior to running EasyApache, then uncommenting those lines after it builds. I'll add that information to the guide after I confirm the best way to do it within the next couple of days.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
It is possible to run a million apps under any account. There aren't restrictions on the number of applications per account.

I did end up revising where the RailsBaseURI is placed to allow multiple applications. So long as it is in .htaccess on /home/username/appname/public/.htaccess (the new how-to above details how to do that), then you can have however many applications you'd like per account.