Difference between revisions of "Redmine"

From Blue-IT.org Wiki

(do it the Ubuntu way (debs and ppa))
(Redmine 2.x and Ubuntu 14.04)
Line 2: Line 2:
  
 
== Install Ruby, Rails and Redmine manually with rvm, redmine sources for apache2 ==
 
== Install Ruby, Rails and Redmine manually with rvm, redmine sources for apache2 ==
After having a lot of problems installing ruby and switching between versions, I decided to go with rvm, the standard installation script for ruby. Also I decided to use the stock redmine installation.
+
After having a lot of problems installing ruby and switching between versions with the ubuntu packaging system (see [[#Do_it_the_Ubuntu_way_.28debs_and_ppa.29]], I decided to go with rvm, the standard installation script for ruby. Also I decided to use the stock redmine installation.
  
 
For installing ruby I followed the instructions here:
 
For installing ruby I followed the instructions here:

Revision as of 14:18, 26 October 2015

Redmine 2.x and Ubuntu 14.04

Install Ruby, Rails and Redmine manually with rvm, redmine sources for apache2

After having a lot of problems installing ruby and switching between versions with the ubuntu packaging system (see #Do_it_the_Ubuntu_way_.28debs_and_ppa.29, I decided to go with rvm, the standard installation script for ruby. Also I decided to use the stock redmine installation.

For installing ruby I followed the instructions here:

Other helpful sites for dealing with ruby are:


Mainly I followed the installation instructions for installing redmine from RedmineCRM but I used apache2 and an actual version of redmine:

Before you start, it might be wise to create a swap file first, because the compilation can take a lot of time:


First make a backup of redmine

cp -av /etc/redmine /etc/redmine.bak
cp -av /var/lib/redmine /var/lib/redmine.bak
cp -av /usr/share/redmine /usr/share/redmine.bak
# Backup your database:
# mysqldump / psql --dumpall ... > redmine.sql # you should know how to this 

Then we will uninstall all packages concerning ruby, rails and redmine from the system ...

apt-get remove --purge ruby*

... and cleanup directories:

/usr/local/bin
rm -rf /var/lib/gems

Then ee will copy the latest redmine version and then setup ruby and Co. You need subversion installed for this method, but you can also download with wget:

#> cd /srv/www
#> svn co http://svn.redmine.org/redmine/branches/3.1-stable redmine

Set permissions:

cd /srv/wwww/redmine
mkdir public/plugin_assets
chown -R www-data:www-data files log tmp public/plugin_assets config.ru
chmod -R 755 files log tmp public/plugin_assets
[ -f Gemfile.local ] || touch Gemfile.local
chmod 644 Gemfile.local
chown www-data.www-data Gemfile.local

Now copy over all files from your old installation

rm files/delete.me
cp /etc/redmine/
cp -av /var/lib/redmine.bak/default/files files
cp -av /usr/share/redmine.bak/public/themes/* public/themes/.
cp -av /usr/share/redmine.bak/plugins/* plugins/.
cp -av /etc/redmine.bak/default/database.yml config/.
chmod 644 config/database.yml


Setup ruby:

sudo su 
# You should consider install ruby not as root, but a special user
# and add that user to the group rvm
cd ~
apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -L https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install 2.2.3
rvm use 2.2.3 --default
ruby -v
#> ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

Gem install directory and install bundler:

echo "gem: --no-ri --no-rdoc" > ~/.gemrc
gem install bundler

Install rails:

gem install rails -v 4.2.4

For preparing setting up postgres an mysql see:

or my sections which follow this howto

Then install the database gems for postgresql ...

gem install pg
gem install activerecord-postgresql-adapter
bundle install

... or mysql

gem install mysql2

Time to prepare the installation for apache2 mod_passenger:

gem install passenger --no-ri --no-rdoc


Now you can start the compilation and configuration script for apache2. The compilation script passenger-install-apache2-module tells you about everything you need to do (installing additional devs, the lines for the apache configuration file. So it is very likely that you have to install the devolopment files first:

apt-get install apache2-threaded-dev libaprutil1-dev libapr1-dev

No start the script ... which can take some time ... :

passenger-install-apache2-module

... so go and get a green tee or make your dishes ;-) You are almost there.

The script output (which you should read carefully!) tells you for example add the corresponding lines from the compilation script output in your virtual server file:

  LoadModule passenger_module /usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.21/buildout/apache2/mod_passenger.so
  <IfModule mod_passenger.c>
    PassengerRoot /usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.21
    PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.2.3/wrappers/ruby
  </IfModule>

Then you have also to alter the section for ruby at the beginning of my virtualhosts file to point to the right gems directory:

SetEnv GEM_HOME /usr/local/rvm/gems/ruby-2.2.3/


Install all necessary dev-packages for compiling your database connection and e.g. rmagick (see later sections):

Now install configure the database.yml and then change to your redmine directory. Pay attention: if you have some plugins, which need special treetment (e.g. special gems), you probably have to resolve this issues before:

cd /srv/www/redmine
bundle install

Migrate your database: and plugins

cd /srv/www/redmine
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake redmine:plugins RAILS_ENV=production

Generate a secret token:

bundle exec rake generate_secret_token 

Restart redmine (because we user passenger - see:

touch tmp/restart.txt
service apache2 start

Now everything should work ;-) As I said before, with this method I did not have any single problem. With the next method, using the debian packages I had a lot of trouble. This is sad, because I like the debian packaging.

Do it the Ubuntu way (debs and ppa)

Hint: this might be a pain when it comes to update ruby, rails or redmine. So I decided to go with rvm (see above) which led me to a fully functional redmine version within 1 hour. I also had to look into some logfiles, but it was less problematic than dealing with the ubuntu packages. Plus: I could choose the ruby, rails and redmine version I liked without any hassle. --Apos (talk) 19:31, 25 October 2015 (CET)

(Credits goto an excerpt from https://gist.github.com/subchen/9a78c399ec150544ac4d / THANKS)

[...]

see http://brightbox.com/docs/ruby/ubuntu/

ruby 1.9.3

sudo apt-get install ruby
sudo apt-get install ruby-dev # THIS IS IMPORTANT FOR SOME GEMS TO INSTALL !!!

ruby 2.1

sudo apt-get install python-software-properties
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby2.1 
sudo apt-get install ruby2.1-dev # THIS IS IMPORTANT FOR SOME GEMS TO INSTALL !!!

switch to 2.1

sudo update-alternatives --remove ruby /usr/bin/ruby2.1
sudo update-alternatives --remove irb /usr/bin/irb2.1
sudo update-alternatives --remove gem /usr/bin/gem2.1

OR (check your version of ruby, rdoc and gem!)

sudo update-alternatives --remove ruby /usr/bin/ruby1.9.1
sudo update-alternatives --remove ruby /usr/bin/rdoc1.9.1
sudo update-alternatives --remove gem /usr/bin/gem1.9.1

Then update the alternatives to ruby 2.1

sudo update-alternatives \
     --install /usr/bin/ruby ruby /usr/bin/ruby2.1 50 \
     --slave /usr/bin/irb irb /usr/bin/irb2.1 \
     --slave /usr/bin/rake rake /usr/bin/rake2.1 \
     --slave /usr/bin/gem gem /usr/bin/gem2.1 \
     --slave /usr/bin/rdoc rdoc /usr/bin/rdoc2.1 \
     --slave /usr/bin/testrb testrb /usr/bin/testrb2.1 \
     --slave /usr/bin/erb erb /usr/bin/erb2.1 \
     --slave /usr/bin/ri ri /usr/bin/ri2.1
update-alternatives --config ruby
update-alternatives --display ruby

[...]

If something goes wrong with your ruby version you can manually set the links for ruby:

ln -s /usr/bin/ruby2.1 /usr/bin/ruby
ln -s /usr/bin/irb2.1 /usr/bin/irb
ln -s /usr/bin/rake2.1  /usr/bin/rake
ln -s /usr/bin/gem2.1  /usr/bin/gem
ln -s /usr/bin/rdoc2.1  /usr/bin/rdoc
ln -s /usr/bin/testrb2.1  /usr/bin/testrb
ln -s /usr/bin/erb2.1  /usr/bin/erb
ln -s /usr/bin/ri2.1  /usr/bin/ri

Update your apache config

The virtual host file must point to the right ruby version:

see: Apache_2.4

Update and install your bundle

Then update and install your libs necessary to run redmine - this will update and install all neccesary dependencies:

sudo cd /usr/share/redmine

This is alway necessary if you switch to a new ruby version!:

sudo gem install bundler

Install all your bundles:

sudo bundle install


This might give you some faults, you have to resolve and google for!

e.g. an error for the rmagick gem, after googling I resolved that with:

apt-get install libmagickwand-dev

Then again to check, if everything is in place:

vim Gemfile.local

[...]
gem 'rmagick'
sudo bundle install

Probably you need to manually create a local Gemfile (see next section about Postgresql).

Postgres

If you are using postgresql for database server:

Install development files (gcc is needed for compiling pg) :

apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev autoconf libc6-dev ncurses-dev automake libtool

On a 64bit environment there could be come the following error:

/usr/include/ruby-2.0.0/ruby/ruby.h:24:25: fatal error: ruby/config.h: No such file or directory

Then you have to symlink the library path this way:

mkdir /usr/include/i386-linux-gnu/
ln -s /usr/include/ruby-2.0.0 /usr/include/i386-linux-gnu/ruby-2.0.0


Install the Postgres PPA for the development files:

http://www.postgresql.org/download/linux/ubuntu/

And the development files for your installed postgresql version:

apt-get install postgresql-server-dev-PG_VERSION
# e.g.: postgresql-server-dev-9.3
apt-get install libdbd-pg-ruby
apt-get install ruby2.0-dev:i386

Create a local Gemfile:

cd /usr/share/redmine
vim Gemfile.local

# Gemfile.local
gem 'activerecord-postgresql-adapter'
gem 'pg'

Then the add the following gems

cd /usr/share/redmine
gem install pg
gem install activerecord-postgresql-adapter
bundle install

Apache 2.4

In your virtual hosts section include this:


[...] 

ServerAlias projects.yourserver.com

#  If you updated to ruby 2.1.0 - also for others!
SetEnv GEM_HOME /usr/lib/ruby/gems/2.1.0
DocumentRoot /usr/share/redmine/public
 <Directory /usr/share/redmine/public>
   Options -MultiViews
   AllowOverride All
   Require all granted
</Directory>
 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn
 CustomLog /var/log/apache2/access.log combined
 ErrorLog /var/log/apache2/error.log
 ServerSignature Off

 [...]

Redmine 2.x and Ubuntu 12.04

Man problems mentioned are solved using a recent version of redmine.

Together with [Zentyal] you can use [LDAP] to authenticate users of a Samba4 domain.

[ UPDATE --Apos (talk) 15:54, 16 September 2015 (CEST) ] Do not use this ppa with Ubuntu 14.04 LTS because it updates Redmine from the stable 2.4.2 version to the 2.5.x which - my case - produced trouble, trouble, trouble.

Use the ppa for redmine on ubuntu 12.04 LTS:

Then use this guide:

Plugins

  1. Create the directory /usr/share/redmine/plugins
  2. Put plugins into this directory
  3. run the as explaned in http://www.redmine.org/projects/redmine/wiki/Plugins
rake redmine:plugins:migrate RAILS_ENV=production

LDAP with Zentyal

--Apos (talk) 10:27, 2 November 2013 (CET)

>>> See LDAP with Zentyal 3.2.

Redmine 1.x on Debian Squeeze (6.x)

Redmine Bugs

width of attached images

vim ./public/stylesheets/application.css +740
#content .wiki img {
           max-width: 98%;
}

Possible other solutions:

Fixing a bug using svn

vim /usr/share/redmine/lib/redmine/scm/adapters/subversion_adapter.rb
# SVN executable name
-        SVN_BIN = "svn"
+        SVN_BIN = "/usr/bin/svn"

Installation mit Postgresql und Apache2 mod_passenger

Prerequisites:

  • postgresql server (8.4) installation
  • apache2 with virtual hosts

Debian will configure database and permissions automatically! Be prepared to have an database password for postgres handy.

Redmine 1.1.x

apt-get install redmine redmine-pgsql ruby-git libapache2-mod-passenger librmagick-ruby

Update to the most recent version

aptitude -t squeeze-backports install redmine

Redmine 1.3.x

Or via testing:

root@server:~#  vim /etc/apt/sources.list.d/testing.list
deb http://yourmirror/debian/mirror/ testing main non-free contrib
deb http://security.debian.org/ testing/updates main contrib non-free
deb-src http://security.debian.org/ testing/updates main contrib non-free

and

root@server:~# vim /etc/apt/preferences.d/pinning 
Package: *
Pin: release n=squeeze
Pin-Priority: 900

Package: *
Pin: release a=testing
Pin-Priority: 80

then

root@server:~# apt-get update &&  aptitude -t testing install redmine redmine-pgsql ruby-git libapache2-mod-passenger librmagick-ruby


Trouble after install

Error with bundler

cd /usr/share/redmine
gem install bundler

Error with Gemfile.lock

Create the file:

cd /usr/share/redmine
touch Gemfile.lock
chmod 664 Gemfile.lock

And fill it with:

GEM
 remote: https://rubygems.org/
 specs:

PLATFORMS
 ruby

DEPENDENCIES

Anyway

Alter permissions.

This is NOT necessary in ubuntu 12.04 and redmine 2.x.

cd /usr/share/redmine/
mkdir files
chown -R www-data:www-data public
chown -R www-data:www-data files
chmod 777 files

Apache virtual host

SERVERIP="1.2.3.4"
MAIL="webmaster@mydomain.com"
DOMAIN="projects.example.com"
DOCPATH="/usr/share/redmine/public"
SSLPATH="/var/customers/ssl"
CUSTOMER="companyname"
CHAINFILE="/where/is/ssl/CAcert_chain.pem"

cat << EOF > ${DOMAIN}.conf
<VirtualHost ${SERVERIP}:443>
  ServerAdmin webmaster@${DOMAIN}
  ServerName  www.${DOMAIN}
  ServerAlias ${DOMAIN}

  DocumentRoot ${DOCPATH}
  <Directory ${DOCPATH}>
    Options -MultiViews
    allow from all
  </Directory>
  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn

  CustomLog /var/log/apache2/access.log combined
  ErrorLog /var/log/apache2/error.log

  ServerSignature Off

  SSLEngine on
  SSLCertificateFile ${SSLPATH}/${CUSTOMER}/${DOMAIN}.cert
  SSLCertificateKeyFile ${SSLPATH}/${CUSTOMER}/${DOMAIN}.key
  SSLCertificateChainFile ${CHAINFILE}

</VirtualHost>
EOF

Dealing with Plugins

Mylyn Connector for Eclipse and Redmine Plugin

1. Install the Redmine Mylin Connector using the update site:

http://redmin-mylyncon.sourceforge.net/update-site/N/ 

2. Install the Redmine Plugin

cd /usr/share/redmine
ruby script/plugin install git://redmin-mylyncon.git.sourceforge.net/gitroot/redmin-mylyncon/redmine-mylyn-connector
# Update
# ruby script/plugin install --force git://redmin-mylyncon.git.sourceforge.net/gitroot/redmin-mylyncon/redmine-mylyn-connector

Timesheet Extension

Download the files (searching the „Downloads“ link) onto the server with

links2 https://github.com/nicStuff/redmine_timesheet_extensions

AFTER installation of plugins

Update the database

cd /usr/share/redmine
rake db:migrate_plugins RAILS_ENV=production

If you have problems use

rake db:migrate_plugins RAILS_ENV=production --trace

Some Basic Plugins

RedmineCRM - open source and commercial plugins

This are absolute MUST-HAVE plugins which are partly free, all open source (!!!) and very pricy, when you will decide to buy some of them.

Support them, they give a lot back to the community through their development of free plugins!

This includes e.g.:

  • Contacts (CRM)
  • Finance (Invoices, Expenses)
  • Nice Themes
  • ...

Not pitfalls, no high prices, no contracts:

All commercial Plugins from easyredmine

Working for a company? Looking for a bigger scope? Probably for more than a couple of employees?

(If you are a stand alone man or woman, better stay with RedmineCRM - its much cheeper ...)

Clipboard image paste

Works with pure JavaScript ;-)

Also see:

Ultraviolet Syntax Highlighting

* http://www.redmine.org/plugins/redmine_ultraviolet

DocPu, Document publishing plugin

* http://www.redmine.org/plugins/redmine_doc_pu

Requires:

gem install RedCloth
apt-get install tetex-base texlive-latex-extra

Hudson

* http://www.redmine.org/plugins/t-ando_redmine_hudson

SVN integration and https

See SVN integration with apache and https


Troubeshooting

Website won't come up

Look at your apache logfile:

tail -f /var/log/apache2/error.log

In my case I copied over the databae.yml, but did not pay attention to the rights:

[!] There was an error parsing `Gemfile`: Permission denied @ rb_sysopen - /srv/www/projects.blue-it.org/config/database.yml. Bundler cannot continue.
chmod 644 /srv/www/redmine/config.yml

Thats it ...

Gemfile.lock - Site won't start

Accessing the Webpage you will get:

There was an error while trying to write to Gemfile.lock. It is likely that 
you need to allow write permissions for the file at path: 

Solution:

sudo apt-get install bundler #Installs ruby-dev, which is ruby1.9-dev
sudo touch /usr/share/redmine/Gemfile.lock
sudo chown www-data:www-data /usr/share/redmine/Gemfile.lock

dpkg-reconfigure redmine witch cache cleaning

dpkg-reconfigure -plow redmine

Migration of plugins

New in 2.0.0 the plugins/engines is removed in 2.0.0.

rake redmine:plugins:migrate RAILS_ENV=production --trace
rake db:migrate_plugins RAILS_ENV=production --trace

Mysql

If you get an error like

No such file or directory - connect(2) for /tmp/mysql.sock (Errno::ENOENT)

Or

database configuration specifies nonexistent mysql adapter (ActiveRecord::AdapterNotFound)

it is likely that your mysl connection cannot be established due to a gem error:

Install the development files for mysql

apt-get install libmysqlclient-dev

Uninstall any old mysql gems:

gem uninstall ruby-mysql
gem uninstall mysql
gem uninstall activerecord-mysql-adapter

Use the new mysql2 adapter:

gem install mysql2

and remove the lines from your Gemfile.local

Wrong version of active...

If using Redmine 2.x and

bundle show | grep active 

shows

activemodel 4.2.1

then you have to downgrade these:

vim Gemfile.local 

gem 'activerecord-mysql-adapter'
gem 'activemodel', '3.2.15'
gem 'actionpack', '3.2.15'
gem 'activesupport', '3.2.15'
gem 'ruby-mysql'

and e.g.

bundle update activemodel


Error:

gem install activemodel -v 3.2.14
gem install actionpack -v 3.2.14
gem install activeresource -v 3.2.14