Install Redmine on CentOS5/RHEL5

Some of these instructions were taken from the following links:

http://blog.itsmine.co.uk/2009/01/22/howto-install-subversion-and-redmine-on-centos5-rhel5/

http://www.redmine.org/wiki/1/RedmineInstall

http://community.engineyard.com/discussions/problems/402-error-on-deploy-rails-requires-rubygems-132-you-have-131-please-gem-update-system-and-try-again

What you will need:

* An Apache server already configured and running as the apache user

* The subversion process setup and the root repository set to /var/svn/repositories

* The virtual hosts DocumentRoot for the Redmine website is located at /var/www/rails/redmine/public

* A MySQL server installed and configured

Install Ruby & RubyGems via RPM

Ruby 1.8.6 is required for all versions of redmine. The current version 1.0.0 which was the current development version from the trunk!!

Download the following rpms from http://pbone.net and install them.

  • ruby-1.8.6.383-6.el5.kb
  • ruby-devel
  • ruby-libs
  • ruby-irb
  • ruby-rdoc
  • ruby-mysql-2.7.3-1.el5
  • rubygems-1.3.1-2.el5.kb
  • subversion-ruby-1.4.2-4.el5_3.1

Once downloaded, install them:

  1. rpm -ivh ruby-*.rpm
  2. rpm -ivh rubygems subversion-ruby

RubyGems

You will need to install rubygems-1.3.2 or higher. by default, CentOS5 comes with rubygems-1.3.1 installed. To resolve this issue:

  1. Download rubygems tarball from here: wget http://rubyforge.org/frs/download.php/55066/rubygems-1.3.2.tgz
  2. Untar it on the files system anywhere you like: tar xvzf rubygems-1.3.2-tgz
  3. Move to the newly created directory: cd rubygems-1.3.2
  4. Update the rubygems files with 1.3.2 version: ruby setup.rb
  5. If you had gems installed under rubygems 1.3.1 version, they will be gone. You will now need to install the necessary gems for redmine now that rubygems 1.3.2 is installed.

Install Ruby & RubyGems via source

You will need gcc installed to compile this and zlib-devel is also required. In addition for Ruby 1.9.2, gems is installed with Ruby.

  1. Download ruby from here: http://www.ruby-lang.org/en/downloads/
  2. Uncompress the file: tar xvzf ruby-X.tar.gz
  3. Move to the ruby directory: cd ruby-X
  4. Select the defaults, it will install into /usr/local/bin and /usr/local/lib by default. ./configure
  5. make
  6. make test
  7. sudo make install

You can verify this worked and ruby and gem is installed by checking the version and listing installed gems.

ruby -v

gem -v

gem list

Install Rails and Rake

You can use gems to install rails and rake.  Make sure to install the correct versions required by Redmine. If you checkout the source from the Redmine repository, you can install a specific Rails version on your machine with:

  1. sudo gem install rails -v=2.3.5
  2. sudo gem install rack -v=1.0.1
  3. sudo gem install mysql

Use yum to get/install the required packages.

$ sudo yum -y install mysql mysql-server mysql-devel ruby-devel

If you have RubyGems installed, you’ll need to get the mysql gem:

$ sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config

You can find out your gem environment with: gem env

gem env
RubyGems Environment:
– INSTALLATION DIRECTORY: /usr/lib64/ruby/gems/1.8
– GEM PATHS:
– /usr/lib64/ruby/gems/1.8
– /home/dlopez/.gem/ruby/1.8
Install passenger gems: gem install passenger, then run passenger-install-apache2-module. This will create the necessary lines to add to Apache rails.conf file.

Create a database for Redmine

I use MySQL so here all I needed:

  1. bash$ mysql -u root -p
  2. mysql > create database redminedb character set utf8;
  3. mysql > grant all privileges on redminedb.* to rmproduser@localhost identified by “password”;
  4. mysql > flush privileges;
  5. quit

Install & Configure Redmine

  1. I chose to checkout redmine from a subversion repository.  You can get the source code by typing: svn co http://redmine.rubyforge.org/svn/tags/1.0.0 redmine
  2. Copy the redmine directory to /var/www/rails/: cp -rvp redmine /var/www/rails/
  3. Give apache ownership of the files: cd /var/www/rails ; chown -R apache.apache redmine
  4. Copy the config/database.yml.example to config/database.yml and add the mysql permissions to the config/database.yml file
  5. Copy the config/email.yml.example to config/email.yml and comment the bottom of the file. I uncommented the section that uses localhost sendmail service.
  6. Generate a session store secret. This is required on the trunk version of Redmine. For the checkout above it is required: rake generate_session_store
  7. Create the database structure, tables and an administrator account: RAILS_ENV=production rake db:migrate
  8. Insert default configuration data in database: RAILS_ENV=production rake redmine:load_default_data
  9. Start the redmine web service: ruby script/server -e production -d
  10. Now you should be able to browse to http://redmineserver.domain.com:3000 and view the default installation

Install & Configure Subversion

  • yum install mod_dav_svn subversion
  • I found this init script here: http://svn.haxx.se/dev/archive-2007-07/0733.shtml Just put it in a file called subversion and place it at /etc/rc.d/init.d/
  • Make sure the script is executable: chmod 755 /etc/rc.d/init.d/subversion
  • Add an option to /etc/sysconfig/subversion to tell subversion where the repositories are located. OPTIONS=’-r /path/to/repos’
  • Add the init script to chkconfig: chkconfig –add subversion
  • Make sure it starts on reboot: chkconfig subversion on
  • Now you can start the subversion service: sudo /sbin/service subversion start
  • Verify it’s running with: ps aux | grep svnserve

Troubleshooting:

/usr/local/lib/ruby/1.8/i686-linux/digest/md5.so: undefined symbol:
rb_Digest_MD5_Init - /usr/local/lib/ruby/1.8/i686-linux/digest/md5.so
(LoadError)

If you get the above error and installed ruby from source, to resolve this I recompiled ruby with a make clean and then reinstalled gems with ruby setup.rb in the rubygems source directory.

ActionView::TemplateError (undefined method `-‘ for nil:NilClass)

I resolved this with the following ruby command:

ruby script/runner -e production ‘Project.rebuild!’

Then restart Apache!

Error: ‘gem_original_require’: no such file to load — zlib (LoadError)

To resolve this issue make sure zlib-devel is installed. *yum install zlib-devel*

then in /opt/ruby/ext/zlib

ruby extconf.rb

make && make install

Plugins

To install the Global Filter plugin:

git clone https://github.com/kumudhachari/global_filter_redmine_plugin.git

cp -R global_filter_redmine_plugin {RedmineRoot}/vendors/plugins/

Moving Redmine to another server.

#1 Install the current version of Redmine on new server.

#2 MySQL dump the database from the old server and import into the new server.

#3 Run: RAILS_ENV=production rake db:migrate

#4 Reload Apache!

Shibboleth Apache Multiple Virtual Host configuration for Moodle

About

Below are steps to configure a shibboleth SP to work with multiple Apache virtual hosts using a single entityID and an Assertion Consumer Service (ACS) and shibboleth’s NativeSPApplicationOverride. More information can be found here regarding NativeSPApplicationOverride

You will need to do this if you are running more than one virtual named host and each virtual host is running it’s own Moodle instance.

In this example, we will use the server names http://www.moodle1.ucla.edu andhttp://www.moodle2.ucla.edu with an entityID of http://www.moodle1.ucla.edu.

Note: You will need shibboleth installed and 2 instances of Moodle installed. You will also have needed to request attribute releases for the entityID and the ACS wherehttp://www.moodle1.ucla.edu is the entityID and http://www.moodle2.ucla.edu is the ACS that is associated with the http://www.moodle1.ucla.edu entityID.

shibboleth2.xml file configuration

Below are the changes I needed to make in the default configuration file. All other settings were left as default from the shibboleth 2.1 installation.

Modifying the host name for the 2 virtual host web servers

<RequestMapper type="Native"><RequestMap applicationId="default">

<Host name="www.moodle1.ucla.edu" ><Path name="default" authType="shibboleth" requireSession="true"/></Host>

<Host name="www.moodle2.ucla.edu" applicationId="moodle2" authType="shibboleth" requireSession="true"/>

</RequestMap></RequestMapper>

Entering entityID

<ApplicationDefaults id="default" policyId="default"entityID="http://www.moodle1.ucla.edu"REMOTE_USER="Shib-eduPersonPrincipalName"signing="false" encryption="false">

Point to Production UCLA IdP

<SessionInitiator type="Chaining" Location="/Login" isDefault="true" id="default"relayState="cookie" entityID="urn:mace:incommon:ucla.edu">

Pulling the MetadataProvider ID Information

<MetadataProvider id="incommon" type="XML"xmlns="urn:mace:shibboleth:2.0:metadata"url="http://wayf.incommonfederation.org/InCommon/InCommon-metadata.xml"backingFilePath="/etc/shibboleth/InCommon-metadata.xml"reloadInterval="28800"></MetadataProvider>

Setup the ApplicationOverride

<ApplicationOverride id="moodle2" entityID="http://www.moodle1.cdh.ucla.edu"/&gt;

Save and close the file. Check the shibboleth configuration file for errors: shibd -t and restart the shibboleth service: service shibd restart

Apache Virtual Host Configuration

Note: The Moodle root for www.moodle1.ucla.edu is at /var/www/html/moodle1 and the Moodle root for www.moodle2.ucla.edu is at /var/www/html/moodle2.

At the bottom of the httpd.conf file there should be a Virtual Hosts section. You will need to uncomment and add the following lines in your httpd.conf file.

Use name-based virtual hosting.NameVirtualHost *:80

<VirtualHost *:80>

ServerAdmin webmaster@ucla.edu

DocumentRoot /var/www/html/moodle1

ServerName www.moodle1.ucla.edu

This section allows for the use of .htaccess files to enable Shibboleth on directories

<Directory "/var/www/html/moodle1">

Options All

AllowOverride All

Order allow,deny

Allow from all

</Directory>

This section is required by Moodle to use Shibboleth authentication along with local authentication by only restricting the index.php file to shib auth.

<Directory /var/www/html/moodle1/auth/shibboleth/index.php>

AuthType shibboleth

ShibRequireSession On

require valid-user

</Directory>

</VirtualHost>

<VirtualHost *:80>

ServerAdmin webmaster@ucla.edu

DocumentRoot /var/www/html/moodle2

ServerName www.moodle2.ucla.edu

This section allows for the use of .htaccess files to enable Shibboleth on directories

<Directory "/var/www/html/moodle2">

Options All

AllowOverride All

Order allow,deny

Allow from all

</Directory>

This section is required by Moodle to use Shibboleth authentication along with local authentication by only restricting the index.php file to shib auth.

<Directory /var/www/html/moodle2/auth/shibboleth/index.php>

AuthType shibboleth

ShibRequireSession On

require valid-user

</Directory>

</VirtualHost>

Save and close the file and check the apache configuration: httpd -t Then restart apache. sudo /sbin/service httpd restart

Configure Moodle to use Shibboleth authentication and local login

For this to work you need to have the require shibboleth directives only restricting the index.php file in the auth/shibboleth/ directory. You can then put a link to auth/shibboleth/index.php page in the login page and should be able to login with both local and shibboleth accounts.

#1. As Moodle admin, under Site Administrator, browse to Users → Authentication → Shibboleth.

#2. Fill in the fields of the form. The fields ‘Username’, ‘First Name’, ‘Surname’, etc. should contain the name of the environment variables of the Shibboleth attributes that you want to map onto the corresponding Moodle variable. For Shibboleth 2.1, these are set in the attribute-map.xml file.

##################################################################### Shibboleth Attributes needed by Moodle: For Moodle to work properly Shibboleth should at least provide the attribute that is used as username in Moodle. It has to be unique for all Shibboleth Be aware that Moodle converts the username to lowercase. So, the overall behaviour of the username will be case-insensitive. All attributes used for moodle must obey a certain length, otherwise Moodle cuts off the ends. Consult the Moodle documentation for further information on the maximum lengths for each field in the user profile. #####################################################################

#3. Save the changes you made on the Shibboleth page.

#4. Browse to Users → Authentication → Manage Authentication to Enable and Disable Shibboleth login. You can control the priority of the failthrough here if you would like as well.

#5. Save the changes.

CCLE UCLAlogin.php page

If you are going to use CCLE UCLAlogin.php page you will need to edit the htpswwwroot variable and hard code the server name.

Example for www.moodle1.ucla.edu Comment this line://$CFG->httpswwwroot = str_replace("http://", "https://", $CFG-httpswwwroot);Enter this instead:$CFG->httpswwwroot ="http://www.moodle1.ucla.edu";