Archive for the ‘redmine’ Category

How to install and configure Postfix on Ubuntu?

I’m trying to configure an incoming email service for receiving issues via email in a Redmine server for a company.

The company uses Lotus Notes and for security reasons, I cannot read email using POP3 or IMAP, only with notes client or notes iWeb. I need an account ( but the company does not generate generic accounts. I neither can use a Gmail account, because they use an authenticated proxy and it’s not possible to check the gmail account (neither I can check another user’s account in the same company). Crazy!

I don’t need to send mails from this account. At least I can use their SMTP server to send the redmine’s mails.

The solution is to create a local mail transfer agent (I’ll use Postfix) in the server where redmine is installed, create a local mail account (, and then redirect all the mail from the user account that administers the redmine to this local account. A bit convoluted, I know, but I have no other choice.

Hands on!

Postfix is a well known Mail Transfer Agent (MTA), and it’s an alternative to the also widely used Sendmail MTA. We’ll use also Courier IMAP and Courier POP3 to retrieve emails. If you want a more detailed explanation, have a look at this Ubuntu HowTo:

In this post I will focus only on the installation and configuration process. This is a schema of our final result (taken from the Ubuntu HowTo):


Postfix schema

Postfix schema


Install Postfix

The first step is to install postfix:

$ sudo apt-get install postfix

You’ll be prompted for your server type. Choose “Internet site”:

Postfix - Internet site

And then enter your domain name (, or in my case

Postfix - Domain name

Once installed, edit the /etc/postfix/ file and add this lines at the end of the file:

inet_protocols = ipv4
home_mailbox = Maildir/

We are telling postfix to use IPv4 protocol, and that the folder where the mail will be saved (home/username/Maildir). Extract from the Ubuntu HowTo:

Maildir is a format for an e-mail spool that does not require file locking to maintain message integrity because the messages are kept in separate files with unique names. A Maildir is a directory (often named Maildir) with three subdirectories named tmp, new, and cur. The subdirectories should all reside on the same filesystem.

Another reason to use Maildir format is that Courier IMAP/POP3 servers only work with Maildir format of mailboxes.

Restart postfix to get the new configuration:

 $ sudo service postfix restart 
* Stopping Postfix Mail Transport Agent postfix [ OK ] 
* Starting Postfix Mail Transport Agent postfix [ OK ]

Install Courer POP3 and Courier IMAP

To retrieve the emails from our MailBox, we’ll to install Courier POP3 and Courier IMAP:

$ sudo apt-get install courier-pop

When prompted for creating web-based administration directories, answer No:


courier-pop administration directories

Then install Courier IMAP:

$ sudo apt-get install courier-imap 

Install bsd-mailx

To make some tests sending emails, we need a mail client. Bsd-mailx is a simple command-line mail client:

$ sudo apt-get install bsd-mailx 

Install Mozilla Thunderbird

Finally, to make the final tests, we’ll install Mozilla Thunderbird. If you haven’t already installed, just type:

$ sudo apt-get install thunderbird

Testing the installation

First of all, test your mail server:

$ telnet localhost 25
Connected to localhost.
Escape character is '^]'.
220 l3-ubuntu-12 ESMTP Postfix (Ubuntu)
221 2.0.0 Bye
Connection closed by foreign host.

Lets create some users to test our mail server. Answer the questions to create the users:

$ sudo adduser user1
$ sudo adduser user2

Now change to user1 and send an email to user2:

  • To send a mail to user2, type mail user2
  • Write the subject of the email and press [Enter]
  • Write the body of the email and press [Enter]
  • To send the mail, write a dot (.) and press [Enter]
$ su user1
user1@l3-ubuntu-12:/home/user1$ mail user2
Subject: test mail from user1
This is a test mail from user1

Now check if the email has arrived to user2. To avoid the “Cannot open display” message:

$ su user2
user2@l3-ubuntu-12:/home/user2$ thunderbird 
No protocol specified
No protocol specified
No protocol specified
No protocol specified
Error: cannot open display: :0

switch to user2 with sux. Sux is a wrapper around su to transfer your X credentials, thus you can open Thunderbird with user2 (install with sudo apt-get install sux):

$ sux user2
xauth: file /home/user2/.Xauthority does not exist
user2@l3-ubuntu-12:/home/user2$ thunderbird

Open Thunderbird and create a new account:

Press Skip this and use my existing email:

Thunderbird-New account

Enter the user2 account settings:

Thunderbird - user2 account settings

Press Continue. If you get this error:

Thunderbird failed to find the settings for your email account

Thunderbird - Error


Then restart postfix and try again:

$ sudo service postfix restart

Now the configuration must be retrieved. I choose the POP3 configuration for my email account:

Thunderbird - correct settings
And press Done. You get this warning screen because we are not using encryption (maybe in a later post, for the purpose of testing the email it’s enough with this). Check I understand the risks and press Done.

Thunderbird - warning screen

And now you can retrieve the email for user2.

Thunderbird - Inbox

If you try to send a message you’ll get this error:


Thunderbird - Error sending mail


You have to get the local certificate and confirm the security exception to send mails:

Thunderbird - Confirm ecurity exception


And now just pray for this to work in the foo company!

Do you liked this HowTo? PLease leave your comments below.


Subversion: modify the comment of a commit

October 5, 2012 Leave a comment

When I forget to comment a subversion commit, or if I want to change it, there is no easy way to edit or modify the commit.

But in the documentation you can find two ways to change it:

I use the second one, using svnadmin and the –bypass-hooks option:

$ svnadmin setlog REPOS_PATH -r N FILE

where REPOS_PATH is the path to the repository location, N is the revision number whose log message you wish to change, and FILE is a file containing the new log message.

For instance, to add a comment to a previous revision (13), I type this command:

$ echo "My new comment for this commit (#124)" > log.txt

$ svnadmin setlog ~/svn/myproject/ -r 13 log.txt --bypass-hooks

The (#124) is because I use redmine as project manager. Once added the new comment. I cannot see it at redmine. But that’s easy. Simply delete the repository and add it again to redmine, and you’ll see the content updated.

Categories: redmine, subversion Tags: , , ,

Restore MySQL database without a mysqldump backup

September 6, 2011 2 comments

Restore the database

I have had a hard disk error and I need to restore my old redmine database to the newer installation of redmine in Ubuntu 11.04 (

I have the old data directory accessible, but no recent mysqldump of my database, so I just want to copy the old data directory to the newly created redmine database.

First, I take a backup of the current version:

$ mysqldump -u root -p'root_password' redmine | gzip > redmine_mysql.gz

Shutdown the database:

$ sudo service mysql stop

Delete all of MySQL database files (with root user or mysql user):

$ sudo su -

$ cd /var/lib/mysql/

$ rm *

Install a new empty database schema:

$ mysql_install_db
Installing MySQL system tables...
Filling help tables...

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h <machinename> password 'new-password'

Alternatively you can run:

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with
cd /usr/mysql-test ; perl

Please report any problems with the /usr/scripts/mysqlbug script!

Start the database and then assign a password to the root user:

$ sudo service mysql start
$ mysqladmin -u root password 'new-password'

Shutdown again the database, and copy all of the files of the old filesystem to the newly created database, overwriting all the files:

$ sudo service mysql stop
$ sudo su -
$ cp -R /old_file_system/var/lib/mysql/* /var/lib/mysql
$ chmod -R 660 /var/lib/mysql/

And finaly, restart the database:

$ sudo service mysql start

Permissions error

If you get this error selecting tables:

mysql> select * from attachments;
ERROR 1017 (HY000): Can't find file: './redmine_default/attachments.frm' (errno: 13)

Ensure that you have the propper permissions in the data directory and that belongs to mysql user.
In my case, the data files has the correct permissions:

$ ls redmine_default/attachments.frm
-rw-rw---- 1 mysql mysql  9022 2011-09-06 00:02 attachments.frm

But the directory not:

$ ls redmine_default
drw-rw----  2 mysql mysql     4096 2011-09-06 00:02 redmine_default/

The directory needs 770 permissions:

$ sudo chmod 700 redmine_default

Rollback changes

If something goes wrong, and you need to restore the initial backup, you have to do this:

$ gzip -c -d redmine_mysql.gz | mysql -u root -p redmine

Restore redmine attachments

The attachments are installed under /var/lib/redmine/default/files. To back them up run the following:

<code>$ sudo tar zcPf redmine_attachments.tar.gz /old_file_system/var/lib/redmine/default/files</code>

And to extract to the new location:

<span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">$ sudo tar xvPf redmine_attachments.tar.gz</span></pre>

Install redmine with MySQL in Ubuntu 11.04

September 5, 2011 19 comments

Damaged hard disk, new hard disk, new re-installation of my software!

Based on my previous post (, I reinstalled redmine on Ubuntu 11.04. I also tried to follow without installing Git, but have had a lot of problems.

First, install the required packages (Ruby on Rails), apache modules, and then install redmine:

$ sudo apt-get install ruby rubygems subversion ruby-pkg-tools ruby1.8-dev build-essential apache2-prefork-dev libapache-dbi-perl libapache2-mod-perl2 libdigest-sha1-perl libcurl4-openssl-dev ruby  ruby1.9.1-dev libgemplugin-ruby libgemplugin-ruby1.8 libruby-extras libruby1.8-extras rake libmysqlclient15-dev
$ sudo apt-get install libapache2-mod-passenger
$ sudo apt-get install redmine redmine-mysql

If you like Gantt-charts:

$ sudo apt-get install librmagick-ruby1.8

Create the database for redmine:

$ mysql -u root -p
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine_password';
GRANT ALL privileges ON redmine.* TO 'redmine'@'localhost';

Configure the database settings:

$ cd /usr/share/redmine
$ sudo cp templates/database.yml.template config/database.yml
$ sudo vi config/database.yml

Sample config file using the default MySQL port (3306):

  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: redmine_password
  encoding: utf8

Install Rubygem, because Ubuntu 11.04 has an older version:

$ cd /tmp
$ wget
$ tar xvfz rubygems-1.7.2.tgz
$ cd rubygems-1.7.2
$ sudo mv /usr/bin/gem /usr/bin/gem-ubuntu
$ sudo ruby setup.rb
RubyGems 1.7.2 installed

=== 1.7.2 / 2011-04-05

* 1 Bug Fix:
  * Warn on loading bad spec array values (ntlm-http gem has nil in its cert


RubyGems installed the following executables:
$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Now install Rails and rack

$ sudo gem install rails -v=2.3.11
$ sudo gem install rack -v=1.1.0
$ sudo gem install mysql
$ sudo gem install -v=0.4.2 i18n

Configure redmine:

$ cd /var/www
$ sudo ln -s /usr/share/redmine/public /var/www/redmine
$ sudo chown -R www-data:www-data redmine
$ sudo rake generate_session_store

If you get this error…

rake aborted!
no rakefile found

…just go to the redmine folder and run again… to get this new error:

$ cd /usr/share/redmine
$ sudo rake generate_session_store
NOTE: is deprecated; From /usr/share/redmine/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:100:in `new'.
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted!
uninitialized constant ActiveSupport::Dependencies::Mutex

As stated in Redmine forums, i added this line at the beggining of /usr/share/redmine/config/boot.rb:

require 'thread'

And now…

$ sudo rake generate_session_store
NOTE: is deprecated; From /usr/share/redmine/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:100:in `new'.
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)
WARNING: 'task :t, arg, :needs => [deps]' is deprecated.  Please use 'task :t, [args] => [deps]' instead.
    at /usr/share/redmine/lib/tasks/email.rake:170

But this is only a warning, so you can safeliy ignore it.

Let’s go with the next step:

$ sudo RAILS_ENV=production rake db:migrate
NOTE: is deprecated; From /usr/share/redmine/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:100:in `new'.
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)
WARNING: 'task :t, arg, :needs => [deps]' is deprecated.  Please use 'task :t, [args] => [deps]' instead.
    at /usr/share/redmine/lib/tasks/email.rake:170
<strong>rake aborted!</strong>
undefined local variable or method `version_requirements' for #<Rails::GemDependency:0x7f9ea62268b0>

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

That seems to be due to incompatible version of rubygems:

$ gem list

*** LOCAL GEMS ***

actionmailer (2.3.11)
actionpack (2.3.11)
activerecord (2.3.11)
activeresource (2.3.11)
activesupport (2.3.11)
i18n (0.4.2)
mysql (2.8.1)
rack (1.1.2, 1.1.0)
rails (2.3.11)
rake (0.9.2)

$ rails -v
Rails 2.3.11

$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]

Install rubygems update 1.4.2 (and uninstall any other rubygems version you already have):

$ sudo gem install rubygems-update -v='1.4.2'
$ sudo update_rubygems

To get another error…

$ sudo RAILS_ENV=production rake db:migrate
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)
WARNING: 'task :t, arg, :needs => [deps]' is deprecated.  Please use 'task :t, [args] => [deps]' instead.
    at /usr/share/redmine/lib/tasks/email.rake:170
rake aborted!
No such file or directory - /etc/redmine/default/database.yml

This is more simple!

$ cd /etc/redmine/default
$ sudo ln -s /usr/share/redmine/config/database.yml

And now you finally can configure it:

$ cd /usr/share/redmine
$ sudo RAILS_ENV=production rake db:migrate
$ sudo RAILS_ENV=production rake redmine:load_default_data

And you can test redmine at


Wow, a little more complicated than in 10.10, at least for me!

Updated 05/april/2012

As commented @ilian, if you have this error:

Please install RDoc 2.4.2+ to generate documentation.

Install it:

gem install rdoc -v=2.4.2

Categories: MySQL, redmine, ubuntu Tags: , , , ,

Install redmine with MySQL in ubuntu 10.10

March 22, 2011 3 comments

Again with Redmine ;-D

As you can read in my older post about installing redmine with PostgreSQL (, now at home I’ll give it a try with MySQL, as I’m developing a web page with PHP/MySql.

The steps are basically the same, followed the indications of this link:

I only have had to install and enable the passenger mod for Apache:

$ sudo apt-get install libapache2-mod-passenger

Then, I can access to localhost/redmine, and don’t forget the admin/admin user/password!

Install redmine with postgreSQL in ubuntu 10.10

November 17, 2010 1 comment

I’m looking for a issue tracking system and finally I’ve dicided redmine to give a try. I’ve been testing a little bit (a couple of days) with Jira, Trac and Mantis. I’ve finally decided Redmine because:

– Jira is a good option, a lot of people recommends it, but it’s propietary (altought it’s free for open source projects), but the standalone version lacks a lot of addons that are only available on the hosted (payment) version. In my case I can go on with the standalone version,  but I decided to give a try an open source product.

– Trac seems to be a good choice, but I’ve read some posts saying that it’s developement is slooower.

– Mantis, another interesting choice, but I found the navigation very confusing.

– Redmine: my actual decission. It’s an evolution of Trac, with a good and integrated admin module. I’ll post about my impressions when I’ve been tested it more.

To install it,first you have to install mySQL or postgreSQL. I’ve decided to install postgreSQL 9 (the latest version). You need the PPA in order to install it on Ubuntu 10.10:

$ sudo apt-get install postgresql-9.0 pgadmin3

Then, to install redmine I’ve followed this link:

But when I configure apache I can only see the directory listing of /redmine. Thus, I installed these packages (I don’t think I need all of them, but this worked for me):

sudo apt-get install ruby rubygems subversion ruby-pkg-tools ruby1.8-dev build-essential

sudo apt-get install libapache2-mod-passenger

Then I tried to configure redmine using passenger and voilà, I can access redmine!