Thursday, December 12, 2013

cpanel and ruby on rails

#first, use rvm to install both ruby stable version + rails, run as root:

curl -sSL https://get.rvm.io | bash -s stable --rails


yum install curl-devel

gem install passenger

rvm list
rvm --default 

export APXS2=/usr/local/apache/bin/apxs
passenger-install-apache2-module

next, copy the configuration in the final readme when compilation is done, eg:
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.27/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.27

PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p353/ruby

and paste to :
/usr/local/apache/conf/includes/pre_main_2.conf

then restart apache:
/scripts/restartsrv_httpd

next, to install rails app onto 1 of the account:
mkdir -p /usr/local/apache/conf/userdata/std/2/[username]/[domain]
vi /usr/local/apache/conf/userdata/std/2/[username]/[domain]/rails.conf


ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/[username]/[path-to-rails]/public
<Directory /home/[username]/[path-to-rails]/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>

#rebuild apache config:
/scripts/rebuildhttpdconf

then restart apache:
/scripts/restartsrv_httpd

next, to be able to run bundle install as a shell user:
mkdir ~/bin
ln -s /usr/local/cpanel/3rdparty/bin/git ~/bin/git
then run bundle install at root of rails application.
this will install gems into vendor/bundle

running git to parse ssl from github seems to return certicate error,
to solve this, pre run this as shell user:
git config --global http.sslverify false

then only run bundle install

if you are using json api,
you will need nodejs installed.
install this as root

on centos:
yum install npm
for other os:
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

 for reference:

No comments: