WebFaction
Community site: login faq

Wondering if there is an update on when a Ruby update is expected at WebFaction. I am developing a couple of sites using 1.9.2 at my office, and constantly have syntax errors going backwards to 1.8.7 at WebFaction.

So, any time estimates, or is there a recommended way of using rvm etc. to update our own apps?

thanks,

Peter

asked 03 Jan '12, 13:19

peterbailey
111
accept rate: 0%


Okay, this should do it:

# first, install a rails app from the control panel.
# Use the "Rails 3.1.0 (nginx 1.0.6/Passenger 3.0.9/Ruby Enterprise Edition 1.8.7)" version.

APP_NAME='rails'           # replace with your rails application name (i.e: ~/webapps/$APP_NAME)
PROJ_NAME='hello_world'    # replace with your rails project name     (i.e: ~/webapps/$APP_NAME/$PROJ_NAME)

#### stop the app ###
$HOME/webapps/$APP_NAME/bin/stop    # Also disable the associated cronjob via `crontab -e`

#### install ruby 1.9.2 ####

# do the install:
cd $HOME
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
echo "[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && source \"$HOME/.rvm/scripts/rvm\"  # This loads RVM into a shell session." >> $HOME/.bash_profile

# Now log out and back in  # don't forget this step :)

# re-set your environment variables:
APP_NAME='rails'           # replace with your rails application name
PROJ_NAME='hello_world'    # replace with your rails project name

# check it to make sure it's working:
type rvm | head -n 1       # you should see "rvm is a function"

#### install ruby 1.9.2 ####

rvm install 1.9.2    # take a 5-minute break

# set it as your default and current ruby:
rvm --default use 1.9.2
rvm use 1.9.2

# and ensure that it's right:
ruby --version    # should show ruby 1.9.2 (currently at patch level "p290" as of this writing)

# note, you can switch between ruby versions using:
# rvm use system   # use system ruby (1.8.7)
# rvm use 1.9.2    # use local ruby (1.9.2)
#
# You can also reset everything with:
# rvm reset

#### Installing rvm into passenger ####

# get the ruby version.
RUBY_VERSION=$(echo $(basename $GEM_HOME) | cut -d'-' -f2,3)    # gives something like "1.9.2-p290"

rvm --create use "${RUBY_VERSION}@${APP_NAME}"

# note: in the future, you need to set APP_NAME and PROJ_NAME, then use:
# rvm use "${RUBY_VERSION}@${APP_NAME}"
# in order to "switch" to this ruby app

cd $HOME/webapps/$APP_NAME/$PROJ_NAME/config

# create setup_load_paths.rb . This file generally shouldn't exist already in a new project.
if [[ -f setup_load_paths.rb ]]; then
echo " ---------------------------------------------------------- "
echo "     setup_load_paths.rb already exists. Edit manually.     "
echo " ---------------------------------------------------------- "
else
cat << EOF > setup_load_paths.rb
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    rvm_lib_path = File.join(rvm_path, 'lib')
    $LOAD_PATH.unshift rvm_lib_path
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
  rescue LoadError
    # RVM is unavailable at this point.
    raise "RVM ruby lib is currently unavailable."
  end
end
EOF
fi

# install a new passenger plus gems
cd $HOME/webapps/$APP_NAME/tmp

for file in daemon_controller-0.2.6 fastthread-1.0.7 rack-1.3.2 rake-0.9.2 passenger-3.0.9
do
    wget -q https://files.webfaction.com/pub/installer_files/passenger-3.0.9/${file}.gem
    gem install --no-rdoc --no-ri ${file}.gem
    rm ${file}.gem
done

for file in bundler-1.0.18 erubis-2.7.0 rack-1.3.2 rack-cache-1.0.3 rack-test-0.6.1 rack-mount-0.8.3 tilt-1.1 hike-1.2.1 rack-ssl-1.3.2 rdoc-3.9.4 sprockets-2.0.0 abstract-1.0.0 i18n-0.6.0 multi_json-1.0.3 builder-3.0.0 thor-0.14.6 bcrypt-ruby-3.0.1 polyglot-0.3.2 treetop-1.4.10 tzinfo-0.3.29 mime-types-1.16 mail-2.3.0 activesupport-3.1.0 activemodel-3.1.0 actionpack-3.1.0 railties-3.1.0 actionmailer-3.1.0 activeresource-3.1.0 arel-2.2.1 activerecord-3.1.0 rails-3.1.0 coffee-script-source-1.1.2 execjs-1.2.6 coffee-script-2.2.0 coffee-rails-3.1.1 jquery-rails-1.0.14 json-1.6.0 sass-3.1.7 sass-rails-3.1.1 sqlite3-1.3.4 uglifier-1.0.3
do
    wget -q https://files.webfaction.com/pub/installer_files/rails-3.1.0/${file}.gem
    gem install --no-rdoc --no-ri ${file}.gem
    rm ${file}.gem
done

# point to the right ruby
cd $HOME/webapps/$APP_NAME
rm bin
mv gems gems_deleted
ln -s $GEM_HOME gems
ln -s $GEM_HOME/bin bin
for file in $(find $MY_RUBY_HOME/bin/ -type f); do ln -s $file bin/; done    # ignore "File exists" errors.
cp gems_deleted/bin/start gems_deleted/bin/stop gems_deleted/bin/restart bin/

### install nginx ###
cd $HOME/webapps/$APP_NAME
mv nginx nginx_deleted
mkdir nginx

mkdir -p $HOME/src $HOME/tmp
cd $HOME/src
wget 'http://nginx.org/download/nginx-1.0.11.tar.gz'
tar -xzf nginx-1.0.11.tar.gz

export TMPDIR=$HOME/tmp
$HOME/webapps/$APP_NAME/gems/gems/passenger-*/bin/passenger-install-nginx-module --prefix=$HOME/webapps/$APP_NAME/nginx --nginx-source-dir=$HOME/src/nginx-1.0.11 --extra-configure-flags='none' --auto

# update the GEM_HOME in nginx.conf for both env and passenger_root
cd $HOME/webapps/$APP_NAME
rm ./nginx/conf/nginx.conf
cp ./nginx_deleted/conf/nginx.conf ./nginx/conf/
cd $HOME/webapps/$APP_NAME/nginx/conf
sed -i "s^$HOME/webapps/$APP_NAME/gems^${GEM_HOME}^g" nginx.conf
sed -i "s/passenger\-[^;]*;/$(basename $GEM_HOME/gems/passenger-*);/" nginx.conf

# clean up originals
cd $HOME/webapps/$APP_NAME
rm -r gems_deleted
rm -r nginx_deleted

# restart rails
$HOME/webapps/$APP_NAME/bin/restart

Hope that helps!

permanent link

answered 06 Jan '12, 02:27

ryans ♦♦
5.0k93360
accept rate: 43%

edited 29 Jan '12, 19:23

ryans, I am following your directions for this and got most of the way through. Ran into trouble on the nginx installation with the rvm wrappers - here is the console log... Any Suggestions?

[mbradnam@web215 src]$ $HOME/webapps/paper_caddy/gems/gems/passenger-*/bin/passenger-install-nginx-module --prefix=$HOME/webapps/paper_caddy/nginx --nginx-source-dir=$HOME/src/nginx-1.0.11 --extra-configure-flags='none' --auto
Welcome to the Phusion Passenger Nginx module installer, v3.0.9.

This installer will guide you through the entire installation process. It
shouldn't take more than 5 minutes in total.

Here's what you can expect from the installation process:

1. This installer will compile and install Nginx with Passenger support.
 2. You'll learn how to configure Passenger in Nginx.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.

--------------------------------------------

Checking for required software...

* GNU C++ compiler... found at /usr/bin/g++
 * The 'make' tool... found at /usr/bin/make
 * A download tool like 'wget' or 'curl'... found at /usr/bin/wget
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
Your RVM wrapper scripts are too old. Please update them first by running 'rvm update --head && rvm reload && rvm repair all'.
[mbradnam@web215 src]$ rvm update --head && rvm reload && rvm repair all
ERROR: rvm update has been removed. See 'rvm get' and rvm 'rubygems' CLI API instead
RVM reloaded!
Repairing symlinks...
Symlinks repaired
Repairing archives...
Archives repaired
Regenerating environments...
Regenerating environment file for 'ruby-1.9.2-p290@~'
Regenerating environment file for 'ruby-1.8.7-p352'
Regenerating environment file for 'ruby-1.9.2-p290'
Regenerating environment file for 'ruby-1.9.2-p290@bradapp'
Environments regenerated
Regenerating all wrappers...
Regenerating wrappers for ruby-1.8.7-p352
Regenerating wrappers for ruby-1.8.7-p352@global
Regenerating wrappers for ruby-1.9.2-p290
Regenerating wrappers for ruby-1.9.2-p290@~
Regenerating wrappers for ruby-1.9.2-p290@bradapp
Regenerating wrappers for ruby-1.9.2-p290@global
Wrappers regenerated
[mbradnam@web215 src]$ $HOME/webapps/paper_caddy/gems/gems/passenger-*/bin/passenger-install-nginx-module --prefix=$HOME/webapps/paper_caddy/nginx --nginx-source-dir=$HOME/src/nginx-1.0.11 --extra-configure-flags='none' --auto
Welcome to the Phusion Passenger Nginx module installer, v3.0.9.

This installer will guide you through the entire installation process. It
shouldn't take more than 5 minutes in total.

Here's what you can expect from the installation process:

1. This installer will compile and install Nginx with Passenger support.
 2. You'll learn how to configure Passenger in Nginx.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.

--------------------------------------------

Checking for required software...

* GNU C++ compiler... found at /usr/bin/g++
 * The 'make' tool... found at /usr/bin/make
 * A download tool like 'wget' or 'curl'... found at /usr/bin/wget
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
Your RVM wrapper scripts are too old. Please update them first by running 'rvm update --head && rvm reload && rvm repair all'.
[mbradnam@web215 src]$ rvm update --head && rvm reload && rvm repair allERROR: rvm update has been removed. See 'rvm get' and rvm 'rubygems' CLI API insteadRVM reloaded!
Repairing symlinks...
Symlinks repaired
Repairing archives...
Archives repaired
Regenerating environments...
Regenerating environment file for 'ruby-1.9.2-p290@~'
Regenerating environment file for 'ruby-1.9.2-p290@global'
Regenerating environment file for 'ruby-1.8.7-p352@global'
Regenerating environment file for 'ruby-1.8.7-p352'
Regenerating environment file for 'ruby-1.9.2-p290'
Regenerating environment file for 'ruby-1.9.2-p290@bradapp'
Environments regenerated
Regenerating all wrappers...
Regenerating wrappers for ruby-1.8.7-p352
Regenerating wrappers for ruby-1.8.7-p352@global
Regenerating wrappers for ruby-1.9.2-p290
Regenerating wrappers for ruby-1.9.2-p290@~
Regenerating wrappers for ruby-1.9.2-p290@bradapp
Regenerating wrappers for ruby-1.9.2-p290@global
Wrappers regenerated
[mbradnam@web215 src]$ $HOME/webapps/paper_caddy/gems/gems/passenger-*/bin/passenger-install-nginx-module --prefix=$HOME/webapps/paper_caddy/nginx --nginx-source-dir=$HOME/src/nginx-1.0.11 --extra-configure-flags='none' --auto
Welcome to the Phusion Passenger Nginx module installer, v3.0.9.

This installer will guide you through the entire installation process. It
shouldn't take more than 5 minutes in total.

Here's what you can expect from the installation process:

1. This installer will compile and install Nginx with Passenger support.
 2. You'll learn how to configure Passenger in Nginx.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.

--------------------------------------------

Checking for required software...

* GNU C++ compiler... found at /usr/bin/g++
 * The 'make' tool... found at /usr/bin/make
 * A download tool like 'wget' or 'curl'... found at /usr/bin/wget
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
Your RVM wrapper scripts are too old. Please update them first by running 'rvm update --head && rvm reload && rvm repair all'.
(20 Jan '12, 09:00) Peter_Bailey

Please try running rvm get head instead of rvm update --head. Hope that helps!

(20 Jan '12, 13:37) seanf

In my case $LOAD_PATH.unshift rvm_lib_path was interpreted as an empty shell variable and led to ".unshift". If this happens, you need to manually insert it later.

(01 Feb '12, 15:10) Jan Limpens

Thanks for the script. I ran it successfully and am now getting a "502 – Bad Gateway" error. Any ideas why?

(20 Feb '12, 22:09) closedbracket

It sounds like either (A) you used an incorrect port and not the one assigned by the Control Panel for your original Passenger application, or (B) your application is not running even though it is installed, and you just need to start it.

(20 Feb '12, 22:31) ryans ♦♦

Helpful webfaction engineers - rvm get head worked correctly.

That let me finish going thru the above script line by line, and I got to the end without error.

However, I think I configured something incorrectly - when I run bin/restart I get an error on my port saying the address is already in use e.g. nginx: [emerg] bind()

Looked in the nginx conf file - it had the wrong root (was pointing to old $PROJ_NAME in new $APP_NAME). e.g. should be:

.../webapps/paper_caddy/paper-caddy/public.

I modified this file and tried to restart again - same problem.

Could you take a look please...

permanent link

answered 24 Jan '12, 08:06

Peter_Bailey
1
accept rate: 0%

You can search for and manually kill old PIDs by the open port number. Replace the 12345 at the end with your app's port number,

[you@webx]$ netstat -antuwp | egrep "(^[^t])|(^tcp.*LISTEN)" | grep 12345
tcp        0      0 0.0.0.0:12345              0.0.0.0:*                   LISTEN      8070/httpd.worker

In this case the PID is 8070, you would kill the pid like this,

kill -9 8070

This should force the application on that port to close and the new app to restart without a problem.

(24 Jan '12, 17:23) johns

Running rvm install 1.9.2 makes prompt for root password: password required for 'rhn-channel -l':

How to avoid it?

permanent link

answered 22 Sep '15, 00:31

totumfacky
256
accept rate: 0%

Please submit a ticket detailing your issue here:

https://my.webfaction.com/open-support-ticket

And we can try to figure out why that may be happening for you.

(22 Sep '15, 05:02) NickR ♦♦

Done, ticket is HGQ-790182

(22 Sep '15, 15:19) totumfacky
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×4
×4

question asked: 03 Jan '12, 13:19

question was seen: 5,114 times

last updated: 22 Sep '15, 15:19

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM