Install requirements
bash$ sudo aptitude install mysql-server subversion
bash$ sudo aptitude install ruby rubygems ruby1.8-dev libgemplugin-ruby libgemplugin-ruby1.8 libruby-extras libruby1.8-extras rubygems1.8 rails rake
bash$ sudo aptitude install apache2-threaded-dev apache2 libapache-dbi-perl libapache2-mod-perl2 libdigest-sha1-perl libapache2-svn
Downloading and Installing Redmine
Download the latest release of Redmine from http://www.redmine.org/wiki/redmine/Download or check them out from SVN and place it in /var/www. I'm going to be using the SVN checkout method. Then install it.
bash$ cd /var/www
bash$ svn co http://redmine.rubyforge.org/svn/branches/0.8-stable redmine-0.8
bash$ sudo ln -s redmine-0.8 redmine
bash$ sudo chown -R www-data:www-data redmine-X.X.X.tar.gz
Create mySQL database:
bash$ mysql -u username -ppassword
mysql> create database redmine character set utf8;
mysql> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
mysql> quit;
Configuring the database setting for redmine by copying the config/database.yml.example to config/database.yml and modified the "production" environment.
bash$ cd /var/www/redmine-0.8/config
bash$ sudo cp database.yml.example database.yml
Modified the database.yml "production" environment
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: XXXXXXXX
encoding: utf8
socket: /var/run/mysqld/mysqld.sock
Create the database structure by running the following command under the application root directory:
bash$ cd /var/www/redmine-0.8
bash$ sudo rake db:migrate RAILS_ENV="production"
if you ran into this message, install the correct gem version:
Missing the Rails 2.1.2 gem. Please `gem install -v=2.1.2 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
bash$ sudo gem install -v=2.1.2 rails
Insert the default configuration data into the database by running this command below:
bash$ sudo rake redmine:load_default_data RAILS_ENV="production"
You will be asked for the prefer language, hit ENTER to select english. Then you should see this message if there aren't any error:
Default configuration data loaded.
Passenger in a module for apache2 that allow apache to runs ruby on rails application
bash$ sudo gem install passenger
Go the the apache2 module installation location of the passenger and install it.
bash$ cd /var/lib/gems/1.X/gems/passenger-X.X.X/
bash$ sudo bin/passenger-install-apache2-module
Make sure that you see this message:
The Apache 2 module was successfully installed.
Loading the passenger module for apache2 and then edit the conf file.
bash$ cd /etc/apache2/mods-available
bash$ sudo vi passenger.load
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
bash$ sudo vi passenger.conf
PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.5
PassengerRuby /usr/bin/ruby1.8
Activate the passenger module
bash$ sudo a2enmod passenger
Configure the apache virtual host for redmine
<VirtualHost *:80>
ServerName redmine.server.com
DocumentRoot /var/www/redmine/public
ServerAdmin user@server.com
LogLevel warn
ErrorLog /var/log/apache2/redmine_error.log
CustomLog /var/log/apache2/redmine_access.log combined
<Directory /var/www/redmine/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
If you want the subversion vitual host configuration as well, see below:
<VirtualHost *:80>
ServerName svn.server.com
ServerAdmin user@server.com
ErrorLog /var/log/apache2/svn_error.log
CustomLog /var/log/apache2/svn_access.log combined
<Location /project>
DAV svn
SVNPath /var/lib/svn/project
AuthType Basic
AuthName "Trac system for Server projects"
AuthUserFile "/var/lib/svn/.htpasswd"
Require valid-user
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
</Virtualhost>
Copy the config/email.yml.example to config/email.yml and modified it according to your specification.
Configure for SMTP with no authentication.
production:
delivery_method: :smtp
smtp_settings:
address: smtp.example.com
port: 25
domain: example.com
authentication: :none
Configure for SMTP with authentication.
production:
delivery_method: :smtp
smtp_settings:
address: smtp.example.com
port: 25
domain: example.com
authentication: :login
user_name: username@example.com
password: user_password
The basic idea of this subvesion pre-commit hook is that you can't commit code to the repository without referencing a Redmine ticket. If you try to commit a code without any comment or non-existing reference redmine ticket, you will get an error. There are 2 pre-commit hook scripts, 1 is for the SVN and the other is for Ruby. The SVN hook script will pass the submitted comment string to the ruby scripts, shown below:
#!/bin/bash
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
# change to the current working directory
cd `dirname $0`
# svnlook at the comments being submitted with the commit request
COMMENTS=$($SVNLOOK log -t "$TXN" "$REPOS")
# Holla out to a little ruby pre-commit script. if it fails, exit with a return
# code of 1, which means that errors occurred
/usr/bin/env ruby pre-commit.rb "$COMMENTS" || exit 1
A Ruby pre-commit.rb script will do an error checking and decides if the comments passed from the SVN hook scripts pass the verification stated above.
#!/usr/bin/env ruby
comments = ARGV[0]
if /[a-zA-Z0-9]/ !~ comments
raise "You must include a comment with your commit."
end
if /refs|fixes|closess#([0-9]+)/ !~ comments
raise "You must reference a Redmine issue in your commit comments (e.g. 'refs #1234')."
end
issue_number = comments[/#([0-9]+)/][/([0-9]+)/]
# Change the username, password, hostname, and dbname in the following line
# to match your settings
command_line_output = `/usr/bin/mysql -N -u your_mysql_username -pyour_password
-h mysql.yourhostname.com your_redmine_dbname -e
"SELECT COUNT(*) FROM issues I INNER JOIN issue_statuses S
ON S.id = I.status_id WHERE S.is_closed = 0 AND I.id = #{issue_number};"`
redmine_issue_open = command_line_output[0,1]
if '0' == redmine_issue_open
raise "Issue ##{issue_number} is not in an open state."
end
A patch file is a single file that will list all the changes made to Redmine. It is the preferred way to create and share changes to Redmine.
Creating a patch file
Creating a patch for Redmine is easy. Just follow the following simple steps:
Applying a patch file
To apply a patch file you can use the patch program.
Some errors might occur because there are changes to the same areas of code. If you are familiar with merging code, you can try to merge the changes. Otherwise post for help where you downloaded the patch or in the forums.
Remove a patch file
To remove a patch file you can use the patch program.