Preparing the rails environment for installing Redmine using RVM
For many rails applications to work correctly, specific versions of the components are required, such as the ruby version, the version of rails itself, as well as rake, rubygems, etc. And most likely in your Linux distribution (in my case it is Ubuntu 10.04 LTS Server) the versions of these components will be different. You can go the simple way - put the ruby version you need from the source code, and everything else with rubygems. But we want to get a reliable and reproducible result, and the system, while not turning into a landfill.
To solve this problem, we use RVM (Ruby Version Manager). The following script (redmine-1.2-prepare.sh) prepares the rails environment for installing Redmineversion 1.2 with a database in sqlite format. The web server used is apache2 + passenger. The script creates the redmine user, installs the necessary packages, installs RVM in the redmine user home directory, and then rails environment is built there.
Following the script is an example configuration file for apache2 (redmine.conf) proposed by RVM itself at the end of the installation (only PassengerUser www-data was added by itself, because nobody is used by default).
PS: The script provides the ability to install using a proxy server. The proxy must be set through the environment variables http_proxy and https_proxy.
The script was tested in Ubuntu 10.04 LTS Server
UPDATE : I don’t know whether you have already tried this script or not, but I found one error in it that was made during the “code painting”, I apologize. The line
"[[-s" $ HOME / .rvm / scripts / rvm "]] && source" $ HOME / .rvm / scripts / rvm "&& \"
must have two more backslashes
"[[-s" \ $ HOME / .rvm / scripts / rvm "]] && source" \ $ HOME / .rvm / scripts / rvm "" && \ ".
UPDATE2 : starting with Redmine 1.4.x the script can be simplified a little, because Redmine started using bundler for dependency management.
UPDATE3: The latest scripts are always on the link: http://www.helplinux.ru/wiki/en:kb:redmine-installation
To solve this problem, we use RVM (Ruby Version Manager). The following script (redmine-1.2-prepare.sh) prepares the rails environment for installing Redmineversion 1.2 with a database in sqlite format. The web server used is apache2 + passenger. The script creates the redmine user, installs the necessary packages, installs RVM in the redmine user home directory, and then rails environment is built there.
Following the script is an example configuration file for apache2 (redmine.conf) proposed by RVM itself at the end of the installation (only PassengerUser www-data was added by itself, because nobody is used by default).
redmine-1.2-prepare.sh
#!/bin/bash -e
# Define common variables
USERNAME=redmine
RUN_WITH_USERNAME="sudo -iu $USERNAME http_proxy=$http_proxy https_proxy=$https_proxy"
# Create user with $USERNAME
id $USERNAME || sudo useradd -rm $USERNAME
# Install apache2
sudo apt-get install apache2
# Install RVM and rvm reqirements
sudo apt-get install curl
$RUN_WITH_USERNAME bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
# Install packages suggested by rvm-installer
sudo apt-get install \
build-essential openssl libreadline6 libreadline6-dev curl \
git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 \
libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev \
ncurses-dev automake libtool bison subversion
# Prepare environment for Redmine 1.2
## Define versions
REDMINE_VERSION=1.2
RUBY_VERSION=1.8.7
GEM_VERSION=1.6.2
RAKE_VERSION=0.8.7
RACK_VERSION=1.1.3
I18N_VERSION=0.4.2
RAILS_VERSION=2.3.11
## Install packages necessary to build passenger for apache2
sudo apt-get install libcurl4-gnutls-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
## Prepare
GEM_INSTALL="gem install --no-rdoc --no-ri"
GEM_VERSION_SHORT=${GEM_VERSION//./}
cat << EOF | $RUN_WITH_USERNAME bash -e
[[ -s "\$HOME/.rvm/scripts/rvm" ]] && source "\$HOME/.rvm/scripts/rvm" && \
rvm install $RUBY_VERSION-gems$GEM_VERSION_SHORT && \
rvm use $RUBY_VERSION-gems$GEM_VERSION_SHORT && \
rvm rubygems $GEM_VERSION && \
rvm gemset create redmine$REDMINE_VERSION && \
rvm use $RUBY_VERSION-gems$GEM_VERSION_SHORT@redmine$REDMINE_VERSION
## Install necessary gems
$GEM_INSTALL -v=$RAKE_VERSION rake && \
$GEM_INSTALL -v=$RACK_VERSION rack && \
$GEM_INSTALL -v=$I18N_VERSION i18n && \
$GEM_INSTALL -v=$RAILS_VERSION rails && \
$GEM_INSTALL sqlite3
## Install passenger
$GEM_INSTALL passenger
## Build passenger
passenger-install-apache2-module -a
EOF
redmine.conf
# Passenger
PassengerUser www-data
LoadModule passenger_module /home/redmine/.rvm/gems/ruby-1.8.7-p358-gems162@redmine1.2/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /home/redmine/.rvm/gems/ruby-1.8.7-p358-gems162@redmine1.2/gems/passenger-3.0.11
PassengerRuby /home/redmine/.rvm/wrappers/ruby-1.8.7-p358-gems162@redmine1.2/ruby
# Public directory
DocumentRoot /opt/redmine/redmine-1.2/public
AllowOverride None
Options -MultiViews
PS: The script provides the ability to install using a proxy server. The proxy must be set through the environment variables http_proxy and https_proxy.
The script was tested in Ubuntu 10.04 LTS Server
UPDATE : I don’t know whether you have already tried this script or not, but I found one error in it that was made during the “code painting”, I apologize. The line
"[[-s" $ HOME / .rvm / scripts / rvm "]] && source" $ HOME / .rvm / scripts / rvm "&& \"
must have two more backslashes
"[[-s" \ $ HOME / .rvm / scripts / rvm "]] && source" \ $ HOME / .rvm / scripts / rvm "" && \ ".
UPDATE2 : starting with Redmine 1.4.x the script can be simplified a little, because Redmine started using bundler for dependency management.
UPDATE3: The latest scripts are always on the link: http://www.helplinux.ru/wiki/en:kb:redmine-installation