📜 ⬆️ ⬇️

Redmine + Mercurial project management system on Ubuntu 16.04

As the number of people involved in the project increases, there is a need to somehow organize and manage their activities more effectively. At the initial stage, Google-tables were used for this purpose, but their possibilities are limited, and there was a desire to move to a new level. The study of available project management systems showed that Redmine is the most advanced of the open source systems and even outperforms proprietary systems in some indicators.

Redmine, indeed, has great potential: managing multiple projects, tracking errors, integrating with repositories, cross-references to fixed bugs in commits and commits in bug reports, assigning different user roles to each project, etc. However, the installation procedure is quite complicated, and for some very useful functions, a slight refinement or use of plug-ins is required. I hope that the guide below will help those who want to use Redmine in their projects.

Components


Redmine project management system


Official website

Key features:
')

Mercurial Version Control System


Official website

Cross-platform distributed version control system.

Also need


Web server and database management system. Mysql and Apache are used .

Installation


The instruction is based on a useful, but very outdated instruction.
HowTo Install Redmine 1.2.x with Mercurial and Subversion on Ubuntu Server 10.04 .

Also used the official installation instructions
Redmine Installation Guide .

We assume that we already have a server with Ubuntu Server 16.04 pre-installed on it. Further instructions describe the installation of the control system and auxiliary software.

So, let's begin. First install the LAMP server:

$ sudo tasksel install lamp-server 

During installation, you will need to enter the password of the root user of the MySQL database (not to be confused with the root password of the operating system).

Create a MySQL database and a redmine user to work with it. Instead of [password] insert the desired user password.

 $ mysql -u root -p (  root   MySQL) > create database redmine character set utf8; > create user 'redmine'@'localhost' identified by '[password]'; > grant all privileges on redmine.* to 'redmine'@'localhost'; > exit 

Download Redmine from www.redmine.org/projects/redmine/wiki/Download or by team

 $ wget http://www.redmine.org/releases/redmine-3.3.3.tar.gz 

Unpack Redmine in the / usr / share / redmine directory. Find the config subdirectory and copy config / database.yml.example to config / database.yml. After that, edit the file in order to set the "production" database mode:

 $ sudo cp /usr/share/redmine/config/database.yml.example /usr/share/redmine/config/database.yml $ sudo nano /usr/share/redmine/config/database.yml 

Enter the text and save the file (ctrl + x):

 production: adapter: mysql2 database: redmine host: localhost username: redmine password: "[password]" encoding: utf8 

Install the necessary packages:

 $ sudo apt install ruby ruby-dev build-essential libmysqlclient-dev 

Install Bundler:

 $ gem install bundler 

Now you can install the gems required for Redmine:

 $ cd /usr/share/redmine $ bundle install --without development test rmagick 

Create a random key that Rails will use to encrypt cookie data:

 $ cd /usr/share/redmine $ bundle exec rake generate_secret_token 

Next, create the database structure (execute in / usr / share / redmine):

 $ RAILS_ENV=production bundle exec rake db:migrate $ RAILS_ENV=production bundle exec rake redmine:load_default_data 

Set the necessary access rights:

 $ cd /usr/share/redmine $ sudo chown -R www-data:www-data files log tmp public/plugin_assets $ sudo chmod -R 755 files log tmp public/plugin_assets 

If you wish, you can test the installation of Redmine using the WEBrick web server:

 $ sudo -u www-data bundle exec rails server webrick -e production 

After launching WEBrick, the Redmine start page should be accessible in the browser at http://localhost:3000/

Apache integration


Install Passenger:

 $ sudo apt-get install libapache2-mod-passenger 

Add a symbolic link to the Redmine public directory:

 $ sudo ln -s /usr/share/redmine/public /var/www/redmine 

It is necessary to configure the default user Passenger, for this we edit the file:

 $ sudo nano /etc/apache2/mods-available/passenger.conf 

You need to add the following line and save (ctrl + x):

 PassengerDefaultUser www-data 

As a result, the file should look like this:

 <IfModule mod_passenger.c> PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini PassengerDefaultRuby /usr/bin/ruby PassengerDefaultUser www-data </IfModule> 

Next, create a configuration file redmine.conf for apache:

 $ sudo nano /etc/apache2/sites-available/redmine.conf 

Add the following text 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> 

Connect Passenger and Rewite modules:

 $ sudo a2enmod passenger $ sudo a2enmod rewrite 

Disable the default website and connect redmine:

 $ sudo a2dissite 000-default $ sudo a2ensite redmine 

Set permissions on / tmp / cache Redmine:

 sudo chmod 777 /usr/share/redmine/tmp/cache 

Restart Apache:

 $ sudo service apache2 reload 

Now you can open your favorite browser and go to http://[my site or ip]/redmine or simply http://[my site or ip] . A start page of the Redmine system should appear.

Install mercurial


You need to install the packages:

 $ sudo apt-get install mercurial libapache2-mod-perl2 libapache-dbi-perl libdbd-mysql-perl 

Create a directory in which project repositories will be stored:

 $ sudo mkdir -p /var/hg/ 

Now we want to make the repositories accessible via the http protocol. To do this, create a cgi script:

 $ sudo nano /var/hg/hgwebdir.cgi 

Add the following text and save:

 #!/usr/bin/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) 

Now you need to create the hgweb.config file:

 $ sudo nano /var/hg/hgweb.config 

Add the following content and save:

 [paths] /=/var/hg/** [web] allow_push = * push_ssl = false allowbz2 = yes allowgz = yes allowzip = yes 

Set file permissions:

 $ sudo chown -R www-data:www-data /var/hg/* $ sudo chmod gu+x /var/hg/hgwebdir.cgi 

Now you need to create a conf file for Apache:

 $ sudo nano /etc/apache2/conf-available/hg.conf 

Add the following content and save:

 PerlLoadModule Apache2::Redmine ScriptAliasMatch ^/hg/(.*) /var/hg/hgwebdir.cgi/$1 <Directory /var/hg> Options +ExecCGI </Directory> <Location /hg> AuthType Basic AuthName "Mercurial" Require valid-user AuthUserFile /dev/null #Redmine auth PerlAccessHandler Apache::Authn::Redmine::access_handler PerlAuthenHandler Apache::Authn::Redmine::authen_handler RedmineDSN "DBI:mysql:database=redmine;host=127.0.0.1" RedmineDbUser "redmine" RedmineDbPass "[password]" </Location> 

You also need to create links:

 $ sudo ln -s /etc/apache2/conf-available/hg.conf /etc/apache2/conf-enabled/ $ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/x86_64-linux-gnu/perl5/5.22/Apache2/ 

Enable CGI module and restart Apache:

 $ sudo a2enmod cgi $ sudo service apache2 reload 

Repositories will be available at http://[my site or ip]/hg/* . For example, for a project project, the address would be http://[my site or ip]/hg/project . If the project has a subproject1 project, its repository will be available at http://[my site or ip]/hg/project/subproject1 .

To clone the repository you will need to run:

 $ hg clone http://[my site or ip]/hg/project 

If the cloned project is not public (set in the project settings via the Redmine web interface), then you will need to enter a username and password.

Authorization is carried out on projects Access will be possible only for project participants (managers and developers).

When creating a repository in the Redmine web interface, you must specify the path to it, for example / var / hg / projectname . Repositories in / var / hg must be created manually for each project and initialized with the ( hg init ) command.

After creating a new repository, you need to make sure that it has the necessary access rights:

 $ sudo chown -R www-data:www-data /var/hg/[repository name] 

In principle, it is possible to automate the creation of repositories. Information about this is in the manual at the link HowTo Install Redmine 1.2.x with Mercurial and Subversion on Ubuntu Server 10.04

Email Notification Change Notifications


Redmine supports notifications about various events (changes in the life of bug / features, etc.). In order to use this functionality, it is enough to set up a method for sending emails. This is done in the file /usr/share/redmine/config/configuration.yml The file contains templates for different configurations. You need to uncomment and edit the one you need.

For example:

  email_delivery: delivery_method: :smtp smtp_settings: address: "10.11.12.13" port: 25 authentification: :none enable_starttls_auto: false openssl_verify_mode: 'none' 

Notice that each section in the configuration.yml file is shifted by two spaces. It is important.

Basic notifications should be available after specifying the method of sending emails. However, for notifications about changes in the repository, you need to use an external plugin. You can download it from github.com/lpirl/redmine_diff_email .

Install this plugin. To do this, copy the contents of the plugin to the directory / usr / share / redmine / plugins / redmine_diff_email. In accordance with the installation instructions for the plugin, we modify the file /usr/share/redmine/app/views/repositories/_form.html.erb:

 --- OLD +++ NEW @@ -23,6 +23,7 @@ <% button_disabled = ! @repository.class.scm_available %> <%= repository_field_tags(f, @repository) %> <% end %> +<%= call_hook(:view_repository_form) %> </div> <p> 

The original plugin works with an outdated version of redmine. For redmine-3.3, you need to make changes to the file
/usr/share/redmine/plugins/redmine_diff_email/db/migrate/002_add_repositories_is_diff_email_attached.rb. The contents of the file should be like this:

 class AddRepositoriesIsDiffEmailAttached < ActiveRecord::Migration def self.up add_column :repositories, :is_diff_email_attached, :boolean, :default => false, :null => false Repository.update_all(["is_diff_email_attached = ?", true]) Repository.update_all(["is_diff_email = ?", true]) end def self.down remove_column :repositories, :is_diff_email_attached end end 

After that, in the / usr / share / redmine directory execute the command to update the database:

 bundle exec rake redmine:plugins:migrate RAILS_ENV=production 

Restart Redmine:

 $ sudo service apache2 reload 

If the plug-in is installed correctly, the Redmine Diff Email Plugin will appear in the Administration → Plugins list, and the notification settings will appear in the Redmine SomeProject → Settings tab → Repositories Tab → Edit menu .

In addition, in order for information about changes in repositories to be automatically tracked by Redmine, additional steps need to be taken. First you need to enable WS to manage the repositories and generate an API key. How it's done:

* In the Redmine web interface, in the Administration menu, select Settings
* Go to Repositories tab
* Enable 'Enable WS for repository management'
* Click on the link 'Generate a key'
* Save changes with the 'Save' button

Next, create a script:

 $ sudo nano /var/hg/fetch_changes 

Add the following text and save: (it is necessary to replace [your API key] with the generated API key)

 #!/bin/sh curl "http://localhost/redmine/sys/fetch_changesets?key=[your API key]" > /dev/null 2>&1 

Set permissions for the created file:

 $ sudo chown www-data:www-data /var/hg/fetch_changes $ sudo chmod ug+x /var/hg/fetch_changes 

It remains to add the section [hooks] to /var/hg/hgweb.config, so that the fetch_changes script is executed after each commit:

 [hooks] changegroup = /var/hg/fetch_changes 

Now, with changes in the repository, Redmine will automatically send notifications to project participants.

Source: https://habr.com/ru/post/331006/


All Articles