Saturday, November 20, 2010

How to Install Redmine on Snow Leopard (10.6.4)

The below steps detail how to install redmine on snow leopard -

1. Install XCode/OS X Developer Tools.
-- Use the cd shipped along with the Mac or alternatively you can download
from the below URL -
http://developer.apple.com/technologies/xcode.html
2. Install MySQL server from the below location -
http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg
3. Install MySQL workbench from the below location -
http://dev.mysql.com/downloads/workbench/5.2.html
You can also export path to run the file from command line by editing .profile file -
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
To verify that you’ve updated your path, enter the following command:

echo $PATH
You should see /usr/local/bin at the beginning of the line returned by the system.

4. Install Ruby Gems - Snow Leopard ships with the installation of the below versions
of gems -
Open terminal to check if the right versions are installed -
> rails --version
Rails 2.3.5
> rake --version
rake, version 0.8.3
> gem --version
1.3.5

Alternatively you can install the rails,rack using below commands -
sudo gem install rails -v=2.3.5
sudo gem install rack -v=1.0.1
sudo gem install rake

5. Check out Redmine
create directory Sites under /Library/WebServer
mkdir Sites
cd /Library/WebServer/Sites/
svn checkout http://redmine.rubyforge.org/svn/trunk redmine


There are two options to run Redmine on -
1.Webrick
2.Apache

For option no 2 following additional configuration is needed -
a. Add the below configuration to /etc/hosts
127.0.0.1 redmine.local
b. Install passenger
sudo gem install passenger
sudo passenger-install-apache2-module
Take the output from the installer and put it in /etc/apache2/other/passenger.conf
It will be something like:
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.15
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
The Apache server loads the configuration files in others on start up.

c. Set up Virtual Hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

d.Add to /etc/apache2/extra/httpd-vhosts.conf:
DocumentRoot "/Library/WebServer/Sites"
ServerName localhost

ServerName redmine.local
AllowOverride All
Options Indexes FollowSymLinks -MultiViews
Order allow,deny
Allow from all
RailsBaseURI /redmine/public
RailsEnv production

e. Add to /Library/WebServer/Documents/redmine/config/additional_environment.rb
config.gem "mysql"
config.action_controller.relative_url_root = "/redmine/public"

This completes the configuration for Apache.
6. Install mysql gem
Add the below entry to redmine/config/environment.rb
config.gem "mysql"
after the line
config.gem 'rubytree', :lib => 'tree'
The Snow Leopard comes with 2.8 version of mysql gem installed. This creates issues on 64 bit
operation, so first step is to uninstall the current version
sudo gem uninstall mysql
Install 2.7 version of mysql gem -
export ARCHFLAGS="-arch i386 -arch x86_64" ; sudo gem install -v 2.7 --no-rdoc --no-ri mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config

7. Configure Redmine & Database User setup

Set Up Database - Issue the below commands to setup database
mysql -u root -p
(in mysql prompt issue the below commands)
create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'my_password';
grant all privileges on redmine.* to 'redmine'@'localhost';
Configure Redmine -
cd /Library/WebServer/Sites/redmine
mkdir tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
cp config/database.yml.example config/database.yml
Edit the database.yml
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: redmine (can be your defined password)

8.Issue the below commands for running Rake to complete with Database and table setup -

sudo chown -R _www:_www files log tmp public/plugin_assets
rake generate_session_store
sudo RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data
9. Start the server -

a. Webrick - ruby server - use the below command -
sudo -u _www ruby script/server webrick -e production
Application can be accessed on browser using below URL :
http://localhost:3000/redmine
b. Apache Server - restart apache server using below command -
sudo apachectl start
Application can be accessed on browser using below URL :
http://redmine.local/redmine/public
Additional Reference Information provided at the below sites -

http://www.redmine.org/wiki/redmine/RedmineInstallOSX
http://www.redmine.org/boards/2/topics/17148
http://www.redmine.org/wiki/1/RedmineInstallOSXServer
Also if you want to install the latest version - 1.0.3 of redmine
using a package installer refer to the below URL for download -

http://bitnami.org/stack/redmine