Posts Tagged “RubyEnterpriseEdition”

My new CentOS XEN server has a virtual machine which serves as a dedicated web server. The on the console and in /var/log/messages the following message appeared:

4gb seg fixup, process ruby (pid 20252), cs:ip 73:00e0a636
printk: 151939 messages suppressed.

The console is unusable, because every second a new message appears. The logfile is unusable as well, because it is very large and takes long to open in a text editor and interesting messages are difficult to find. After some google’ing I’ve found the following page with some instructions to fix it. I’ve mixed up various methods, but this is the most robust one to use. It creates a wrapper around the gcc and g++ binaries with the correct parameters.

mv /usr/bin/gcc /usr/bin/gcc.orig
mv /usr/bin/g++ /usr/bin/g++.orig
echo '#!/bin/sh' > /usr/bin/gcc
echo '#!/bin/sh' > /usr/bin/g++
echo 'exec gcc.orig -mno-tls-direct-seg-refs $@' >> /usr/bin/gcc
echo 'exec g++.orig -mno-tls-direct-seg-refs $@' >> /usr/bin/g++
chmod a+x /usr/bin/gcc
chmod a+x /usr/bin/g++

Extract the Ruby Enterprise Edition. Be careful to use a fresh extracted version to compile, because the files will not be recompiled. Compile and install Ruby Enterprise Edition as stated in the manual.

tar zxvf ruby-enterprise-1.8.7-2009.10.tar.gz
./ruby-enterprise-1.8.7-2009.10/installer

Don’t forget to reinstall passenger, and off course reinstall all the gems from the old installation.

Now you can restore gcc and g++ as this will probably break yum updates of gcc and g++.

rm -rf /usr/bin/gcc && mv /usr/bin/gcc.orig /usr/bin/gcc
rm -rf /usr/bin/g++ && mv /usr/bin/g++.orig /usr/bin/g++

Hopefully I’ve saved you guys some time ;-)

Comments No Comments »

Currently I have a Plesk 8.4 installation running on a CentOS 5 VPS. First I had my Ruby on Rails websites running on multiple mongrel servers (cluster) but it took too much RAM of my VPS and it was very complicated to add more websites. So now I’ve installed Passenger (make sure you check the screencast on the Passenger website!) which makes adding websites very easy. Also I’ve installed RubyEnterpriseEdition which reduces the memory needed for Ruby applications, including Ruby on Rails. Below I’ll describe the steps I took to complete this installation.

Passenger

Just follow the steps described on the Passenger website. Run as root:

gem install passenger

The following command verifies if all the dependencies are installed, if not it suggests what rpm’s should be installed and exits. If all the dependencies are met, it compiles the Apache 2 module and installs the module.

passenger-install-apache2-module

Personally I hate installers who do a lot of stuff you can’t control, but this one does only the stuff it should do and will not break your current setup. After the module is installed you need to add the module to Apache. So I created the file /etc/httpd/conf.d/passenger.conf with the following contents:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.1/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.1
PassengerRuby /usr/bin/ruby

Restart Apache.

/etc/init.d/httpd restart

At this point you have installed Passenger and the only thing to make a Ruby on Rails application work, is to point the Apache DocumentRoot directive to the public directory of your Rails application.

RubyEnterpriseEdition

Download RubyEnterpriseEdition (REE), extract the file and run the installer. As described on the REE website.

wget http://rubyforge.org/frs/download.php/38777/ruby-enterprise-1.8.6-20080624.tar.gz
tar xzvf ruby-enterprise-1.8.6-20080624.tar.gz
./ruby-enterprise-1.8.6-20080624/install

This installer will install it’s own Ruby environment to /opt. This is good, because it will not touch your current Ruby environment. After the installation you’ll have a separate gem installed which is version 1.2.0. The version without the gem bulkupdate, which causes a lot of memory problems on VPS’es. The following commands I’ve used to install different gems. Mysql did not install easily, but with the -- --with-mysql it worked. Note the --no-rdoc and --no-ri because we’re on a production environment we don’t need the documentation.

/opt/ruby-enterprise-1.8.6-20080624/bin/gem install --no-rdoc --no-ri rails
/opt/ruby-enterprise-1.8.6-20080624/bin/gem install --no-rdoc --no-ri -v 1.2.6 rails
/opt/ruby-enterprise-1.8.6-20080624/bin/gem install --no-rdoc --no-ri -v 2.0.2 rails
/opt/ruby-enterprise-1.8.6-20080624/bin/gem install --no-rdoc --no-ri mysql -- --with-mysql-config

If you have all the gems installed which you need in your Rails applications, it’s time to switch the Ruby Interpreter to the REE installation, we do this by replacing the PassengerRuby line in the /etc/httpd/conf.d/passenger.conf file.

PassengerRuby /opt/ruby-enterprise-1.8.6-20080624/bin/ruby

Finetuning

Depending on the available RAM on your VPS, you should add the following line to passenger.conf:

PassengerMaxPoolSize 2

To prevent Passenger from invoking to many instances of the Rails app.

Plesk

The only thing you have to do in Plesk is to modify the DocumentRoot. I’ve made a app directory where I deploy my Rails application with Capistrano. Create the file vhost.conf in the config directory of your domain.

DocumentRoot /var/www/vhosts/DOMAIN.COM/app/current/public

After that run the following command to let Plesk reconfigure your domain and add a include for your vhost.conf file.

/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=DOMAIN.COM

Comments 8 Comments »