📜 ⬆️ ⬇️

Preparing rails environments for installing Redmine using RVM

For many rails applications to work correctly, specific versions of components are required, such as the ruby ​​version, the rails version 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 a simple way - put the required version of ruby ​​from the source code, and everything else with the help of 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 a rails environment for installing Redmine version 1.2 with a database in sqlite format. Apache2 + passenger is used as a web server. The script creates the redmine user, installs the necessary packages, installs the RVM into the home directory of the redmine user, and then rails the environment.

Following the script is an example of a configuration file for apache2 (redmine.conf) proposed by RVM itself at the end of the installation (I only added PassengerUser www-data from myself, since the default is nobody).

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


 <VirtualHost *:80> # 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 <Directory /opt/redmine/redmine-1.2/public> AllowOverride None Options -MultiViews </Directory> </VirtualHost> 


PS: The script provides the ability to install using a proxy server. The proxy must be installed via the http_proxy and https_proxy environment variables.

Script verified in Ubuntu 10.04 LTS Server

UPDATE : I don’t know whether you have already tried this script or not, but I found one mistake in it that was made during the “code painting”, I apologize. In line
"[[-s" $ HOME / .rvm / scripts / rvm "]] && source" $ HOME / .rvm / scripts / rvm "&& \"
there must be two more backslashes
"[[-s" \ $ HOME / .rvm / scripts / rvm "]] && source" \ $ HOME / .rvm / scripts / rvm "" && \ ".

UPDATE2 : starting with Redmine 1.4.x, the script can be somewhat simplified, because Redmine began to use the bundler to manage dependencies.

UPDATE3 : The latest versions of scripts are always on the link: http://www.helplinux.ru/wiki/en:kb:redmine-installation

Source: https://habr.com/ru/post/140219/


All Articles