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!

Install macports on Snow Leopard

#1.  Make sure you have Xcode installed.  You can download it from here but you must have an account with Mac Dev Center

#2. Open Terminal (under Utilities in Applications folder)

#3. Checkout the software from the macports repository: svn co http://svn.macports.org/repository/macports/trunk/base/ (Wait for it to finish checking out all files)

#4 cd base

#5 ./configure

#6 make

#7 sudo make install

#8 add /opt/local/bin and /opt/local/sbin to your PATH environment variable in .bash_profile

#9 sudo port -v selfupdate

CloakingDetector

I recently was informed that one of my websites pages was suspected of compromise.  That it was possible a script had been uploaded and was using Cloaking techniques to display spam to Googlebot crawlers.  In investigating the post, there was hidden content that I removed.
I found this tools to check suspected sites of such behavior.

Cloaking Detector

Creating new SELinux policy module

Found the instructions here for editing SELinux policy: http://etbe.blogspot.com/2007/03/creating-new-se-linux-policy-module.html

Edited to allow syslog-ng to run on different port other than port 514. I ran the following command to view the avc denied error messages for syslog-ng: dmesg|grep syslog-ng

SE Linux was not allowing tcp connections for syslog-ng. I don’t have the output of the command as a demonstration. Sorry

As root, run the following:

dmesg | grep syslog-ng | audit2allow -m local > local.te

The -m option to audit2allow instructs it to create a policy module.  The local.te file is below:

module local 1.0;
require {
type syslogd_t;
type port_t;
class tcp_socket { name_bind name_connect };
}
#============= syslogd_t ==============
allow syslogd_t port_t:tcp_socket { name_bind name_connect };

Then use the following commands to create a policy module and package it:

checkmodule -M -m -o local.mod local.te

semodule_package -o local.pp -m local.mod

The result was the object file local.pp and an intermediate file local.mod (which incidentally can be removed once the build is finished).

After creating the module I used the following command to link it with the running policy and load it into the kernel:

semodule -i ./local.pp

Extend VMFS volume with VMware vSphere Client

I was setting up a central logging host. I created a Volume through our EqualLogic SAN of 100GB with thin provisioning.  Then created a virtual host through VMware and gave it the entire 100GB of space for the disk.

I had a configuration error that caused my log files to grow to the entire 100GB over night.  So my disk was now very close to 100% used.  According to these helpful links: http://communities.vmware.com/thread/255173 and http://www.equallogic.com/resourcecenter/assetview.aspx?id=5245

A thin-provisioned volume grows automatically due to application data writes. If later the application frees up space, the space is free in the file system but is not returned to the free space in the PS Series pool. The only way to reduce the physical allocation is to create a new volume, copy the application data from the old volume to the new, and then delete the old volume.
o Example: A file share is thin-provisioned with 1 TB logical size. Data is placed into the volume so that the physical allocation grows to 500 GB. Files are deleted from the file system, reducing the reported file system in use to 100 GB. The remaining 400 GB of physical storage remains allocated to this volume in the SAN.
o This issue can also occur with maintenance operations including defragmentation, database re-organization, and other application operations.

So to get around my EqualLogic storage warnings and alarms, I increased the size of my volume to 125GB.  Now I needed to tell VMware about the change in the VMFS size.  I fired up my VMware vSphere client and browsed one of my ESX servers in our cluster.  Some instructions taken from here: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1003302

  1. Powered off the virtual host.
  2. Click on the “Configuration” tab and selected the “Storage” link.
  3. Right click the Volume you would like to edit.
  4. You will see the device size listed and the VMFS size listed.  Select the “Increase …” button.
  5. This will open a pop up wizard to add an extent to the VMFS file system.
  6. Follow the prompts for the Add Extent wizard to add an extent.
  7. Perform a rescan on every ESX host that is being presented the new LUN so that the additional of the extent is detected.
  8. Selected the virtual host and edited the hard disk size to the increased 25GB size.