HowTo Install Redmine 1.3.x with Mercurial and Subversion on Ubuntu Server 10.04¶
Pre-install¶
- Set the timezone
- Set your hostname
- Map your fully qualified domain name (FQDN) to localhost
Redmine Installation¶
- Install the LAMP stack
- Install the required packages
$ sudo apt-get install build-essential subversion libmysqlclient-dev libdigest-sha1-perl libgemplugin-ruby libgemplugin-ruby1.8 libruby-extras libruby1.8-extras rails rake ruby rubygems rubygems1.8 ruby1.8-dev libopenssl-ruby1.8
-->Update rubygems
In some cases the your system will still be using rubygems 1.5, but you will need a later version. Check which version is installed by typing:
If the version is 1.5: update rubygems
-->Install necessary gems
- Download Redmine into /user/share/redmine directory
- Create an empty MySQL database and accompanying user named redmine for example.
- Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment.
$ sudo cp /usr/share/redmine/config/database.yml.example /usr/share/redmine/config/database.yml $ sudo nano /usr/share/redmine/config/database.yml Modify to the following and save (ctrl+x) production: adapter: mysql socket: /var/run/mysqld/mysqld.sock database: redmine host: localhost username: redmine password: [password] encoding: utf8
- Generate a session store secret.
- Create the database structure, by running the following command under the application root directory:
- Insert default configuration data in database, by running the following command:
- Setting up permissions
- Test using the webrick web server
Apache Integration¶
- Install the required packages
- Add a symbolic link to the public redmine web directory
- Configure Passanger to run as www-data
- Create a new Apache site file
Add the following lines and save (ctrl+x)<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www ServerName myservername RewriteEngine on RewriteRule ^/$ /redmine [R] <Directory /var/www/redmine> RailsBaseURI /redmine PassengerResolveSymlinksInDocumentRoot on </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined </VirtualHost>
For SSL add the following text instead<VirtualHost *:443> ServerAdmin webmaster@localhost DocumentRoot /var/www ServerName myservername SSLEngine On SSLCertificateFile /etc/apache2/ssl/redmine.pem RewriteEngine on RewriteRule ^/$ /redmine [R] <Directory /var/www/redmine> RailsBaseURI /redmine PassengerResolveSymlinksInDocumentRoot on </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined </VirtualHost> - Enable the Redmine website
- Enable the Passenger and Rewite modules and restart Apache
- Test the setup
Mercurial Integration¶
- Install the latest Mercurial release
- Create the hg web directory
- Create the web cgi script file
$ sudo nano /var/hg/hgwebdir.cgi Add the following and save #!/usr/bin/env python # from mercurial import demandimport; demandimport.enable() from mercurial.hgweb.hgwebdir_mod import hgwebdir import mercurial.hgweb.wsgicgi as wsgicgi application = hgwebdir('hgweb.config') wsgicgi.launch(application) - Create the cgi web config file
- Setup permissions
- Create a Apache config file
$ sudo nano /etc/apache2/conf.d/hg.config Add the following and save # Use PerlLoadModule Apache2::Redmine when using apache2, or else you might get weird errors trying to authenticate. PerlLoadModule Apache::Redmine ScriptAlias /hg "/var/hg/hgwebdir.cgi" <Location /hg > AuthType Basic AuthName "Redmine Mercurial Repository" Require valid-user #Redmine auth PerlAccessHandler Apache::Authn::Redmine::access_handler PerlAuthenHandler Apache::Authn::Redmine::authen_handler RedmineDSN "DBI:mysql:database=redmine;host=localhost" RedmineDbUser "redmine" RedmineDbPass "password" </Location> - Add a symbolic link to Redmine.pm
- Enable the required Apache modules and restart Apache
- Create a new test repository and project in Redmine
$ sudo hg init /var/hg/repos/test $ sudo chown -R www-data:www-data /var/hg/repos/test Create a new project with and identifier 'test' In the project Settings > Repository set SCM: Mercurial Path to repository: /var/hg/repos/test Press the 'Create' button Goto to the Repository tab of the test project
- View the test repository in the web browser
Subversion Integration¶
- Install the latest Mercurial release
- Create the svn repository directory
- Setup permissions
- Add a symbolic link to Redmine.pm
- Create a Apache config file
Add the following and savePerlLoadModule Apache::Redmine <Location /svn> DAV svn SVNParentPath "/var/svn" Order deny,allow Deny from all Satisfy any PerlAccessHandler Apache::Authn::Redmine::access_handler PerlAuthenHandler Apache::Authn::Redmine::authen_handler AuthType Basic AuthName "Redmine Subversion Repository" #read-only access <Limit GET PROPFIND OPTIONS REPORT> Require valid-user Allow from [my server ip] # Allow from another-ip Satisfy any </Limit> # write access <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> ## for mysql RedmineDSN "DBI:mysql:database=redmine;host=localhost" RedmineDbUser "redmine" RedmineDbPass "password" </Location> - Enable the required Apache modules and restart Apache
- Create a new test repository
Automate Repository Creation¶
- Enable WS for repository management and generate and API key
- Modify reposman.rb
- Schedule the reposman.rb script to run every minute
Add one of the following lines (not both) and save.
(Note: you will need to replace [my API key] with the API key you generated in step 1)
.
To create subversion repositories add:* * * * * root ruby /usr/share/redmine/extra/svn/reposman.rb --redmine localhost/redmine --scm Subversion --svn-dir /var/svn --owner www-data --url file:///var/svn --key=[my API key] >> /var/log/reposman.log
OR to create Mecurial repositories add:
Automatic refresh of repositories in Redmine¶
- Schedule the fetch_changesets script to run every 15 minutes
- Setup a changegroup script on the Mercurial server to run fetch_changesets after each push to a Mercurial repository
Add the following text and save
(Note: you will need to replace [your API key] the API key you generated in Redmine
Setup permissions
Modify the hgweb.config file
Add the following section and save
Email Integration¶
- Install and configure Sendmail
- Update the Redmine configuration file
Backup to Amazon S3 cloud storage¶
- Create an account at http://aws.amazon.com/
- Create a S3 bucket using the aws management console https://console.aws.amazon.com/ec2/home
- View your Access Keys at https://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key
- Build and install fuse to 2.8.4
- Build and install s3fs 1.61
- Create a s3fs password file
Added your 'Access Key ID' and 'Secret Access Key' separated by a colon
Setup permissions
- Create mounting point
- Mount your S3 bucket
- Test it worked and unmount
- Create upstart job to mount the s3 file system start up
Add the following text and save. - Start the s3 job
- Test it worked
- Create the backup script file
Add the following text and save.#!/bin/bash # Script to backup Redmine files to a mounted storage device # with daily, weekly, monthly backup rotation # Sysadmin email address sysadmin_email="admin@domain.com" # What to backup db_dump_file="/usr/share/redmine/db/redmine-database-dump.sql" backup_files="$db_dump_file /usr/share/redmine/files /var/hg /var/svn /etc/apache2/conf.d/hg.conf" backup_files="$backup_files /etc/apache2/sites-available/redmine /etc/init/s3.conf /etc/cron.d/redmine" backup_files="$backup_files /usr/local/bin/backup-redmine.sh" # Where to backup to backup_dir="/mnt/s3" # Set database access redmine_db_name="redmine" redmine_db_user="redmine" redmine_db_password="password" # Encryption encrypt="true" secret_passphrase="password" # Set rotation schedule in units of days ( 0 = disabled ) daily_remove_older_than=6 weekly_remove_older_than=31 monthly_remove_older_than=62 # Redirect stderr to a log file error_log="/tmp/backup-redmine.log" exec 6>&2 exec 2>$error_log on_exit() { # Restore IO output exec 2>&6 6>&- # Check for errors if [ -s "$error_log" ]; then logger -t "$0" -s "#### Backup Failed ####" logger -t "$0" -s -f "$error_log" cat "$error_log" | mail -s "Backup failed!" $sysadmin_email else logger -t "$0" -s "Backup Complete" fi # Clean up rm -f $error_log } trap on_exit EXIT SIGHUP SIGINT SIGQUIT SIGTERM # Setup variables for the archive filename. hostname=$(hostname -s) date_stamp=`date +%Y-%m-%d` # Date p e.g 2011-12-31 date_day_of_week=`date +%A` # Day of the week e.g. Monday date_day_of_month=`date +%e` # Date of the Month e.g. 27 # Is the backup directory mounted? mount | grep -sq "$backup_dir" if [ $? != 0 ]; then echo "backup destination ${backup_dir} is not mounted" >&2 exit 1 fi # Delete old archives find "${backup_dir}" -mtime +"$monthly_remove_older_than" -type f -name "${hostname}_fullbackup_monthly*" -exec rm {} \; find "${backup_dir}" -mtime +"$weekly_remove_older_than" -type f -name "${hostname}_fullbackup_weekly*" -exec rm {} \; find "${backup_dir}" -mtime +"$daily_remove_older_than" -type f -name "${hostname}_fullbackup_daily*" -exec rm {} \; # Determine the backup schedule if [[ $monthly_remove_older_than -gt "0" && $date_day_of_month == "1" ]]; then schedule="monthly" elif [[ $weekly_remove_older_than -gt "0" && $date_day_of_week == "Saturday" ]]; then schedule="weekly" elif [[ $daily_remove_older_than -gt "0" ]]; then schedule="daily" else echo "Invalid backup rotation schedule" >&2 exit 1 fi archive_file="${backup_dir}/${hostname}_fullbackup_${schedule}_${date_stamp}.tgz" # Dump the redmine database rm -f "${db_dump_file}" mysqldump --user="${redmine_db_name}" --password="${redmine_db_password}" "${redmine_db_name}" > $db_dump_file # Write the archive file to the backup directory if [ $encrypt == "true" ]; then tar czP ${backup_files} | gpg -c -z 0 --yes --no-use-agent --passphrase="${secret_passphrase}" -o "${archive_file}.gpg" else tar czfP "${archive_file}" ${backup_files} fi if [ -s "$error_log" ]; then exit 1 else exit 0 fi - Setup permissions
- Schedule the backup to run once a day at 12am
- Test the script