Configure RoundCube on Debian 8 (Jessie) - Perfect Server Debian 8 (Apache, BIND, Dovecot, ISPConfig 3)

Debian 8 (Jessie) doesn't contain RoundCube in it's repositories. Why, I don't know :) . In ISPConfig3, Perfect Server, Debian 8, you get SquirrelMail, but I don't like how it looks. With some trouble setting it up, I managed to configure RoundCube on Debian 8 and make it wokring with ISPConfig3. Used many sources to make it work and decided to create this manual that you’re reading.

I presume that you have configured your server with Perfect Server Debian 8 (Apache, BIND, Dovecot, ISPConfig 3) configuraton . Also, password plugin and Sieve support didn’t worked immediately, so I explained in PART2 and 3 how it is fixed.

My server is on 192.168.15.83, so you change your IP during setup

NOTE: You do this on your own risk. Backup everything before changing configuration files or anything else on your server.

This manual consists from three parts:

  • PART 1 - Installing and configuring RoundCube to work with ISPConfig3.
  • PART 2 - Configure “password change” plugin for RoundCube.
  • PART 3 - ManageSieve server support

1. PART 1 - Installing and configuring RoundCube to work with ISPConfig3.

1.1. Existing webmail app

If you already have SquirrelMail (or any other webmail app), you need to disable it. You can uninstall it (apt-ger remove squirrelmail) or comment-out /webmail alias defined in squirrelmail.conf.

Personaly, I choose to rename a config file: mv /etc/apache2/conf-enabled/squirrelmail.conf /etc/apache2/conf-enabled/squirrelmail.conf.disabled

1.2. Creating a Remote User in ISPConfig3

ISPConfig3 plugins for RoundCube work over ISPConfig's API. If you want to use this API, you need the Remote User. Open ISPConfig web page and login. My ISPConfig server is located on URL: Creating a user: System > User Management > Remote Users and click on the Add new user button. Username: roundcube (you choose) Password: rmisproundcube (you choose). ... and enable the following functions: · Server functions · Client functions · Mail user functions · Mail alias functions · Mail spamfilter user functions · Mail spamfilter policy functions · Mail fetchmail functions · Mail spamfilter whitelist functions · Mail spamfilter blacklist functions · Mail user filter functions Then click on Save, on the bottom of the page.

1.3. Install TinyMCE & RoundCube

TinyMCE apt-get install tinymce

1.4. RoundCube

You can't install round RoundCube on Debian 8 using apt-get istall roundcube....

Instead, you must install it manually.

cd /tmp

Download latest RoundCube from https://roundcube.net/download/. At the moment of wtiting this manual, URL to the latest RoundCube is https://downloads.sourceforge.net/project/roundcubemail/roundcubemail/1.1.2/roundcubemail-1.1.2-complete.tar.gz

Note: download COMPLETE package

wget https://downloads.sourceforge.net/project/roundcubemail/roundcubemail/1.1.2/roundcubemail-1.1.2-complete.tar.gz

tar xzvf roundcubemail-1.1.2-complete.tar.gz 

(extracted to /tmp/ roundcubemail-1.1.2) mkdir /usr/share/roundcube - (I created a roundcube directory where SquirrelMail is)

cp -r roundcubemail-1.1.2/. /usr/share/roundcube/

Open roundcube config file vim /etc/apache2/conf-enabled/roundcube.conf

NOTE – if file does not exists, create it:

touch /etc/apache2/conf-enabled/roundcube.conf
vim /etc/apache2/conf-enabled/roundcube.conf

Copy/Paste configuration bellow into that file:

x
1
# Uncomment them to use it or adapt them to your configuration
2
Alias /roundcube/program/js/tiny_mce/ /usr/share/tinymce/www/
3
Alias /roundcube /usr/share/roundcube
4
Alias /webmail /usr/share/roundcube
5
6
# Access to tinymce files
7
<Directory "/usr/share/tinymce/www/">
8
      Options Indexes MultiViews FollowSymLinks
9
      AllowOverride None
10
      Order allow,deny
11
      allow from all
12
</Directory>
13
14
<Directory /usr/share/roundcube/>
15
  Options +FollowSymLinks
16
  DirectoryIndex index.php
17
18
  <IfModule mod_php5.c>
19
    AddType application/x-httpd-php .php
20
21
    php_flag magic_quotes_gpc Off
22
    php_flag track_vars On
23
    php_flag register_globals Off
24
    php_value include_path .:/usr/share/php
25
  </IfModule>
26
27
  # This is needed to parse /usr/share/roundcube/.htaccess. See its
28
  # content before setting AllowOverride to None.
29
  AllowOverride All
30
  order allow,deny
31
  allow from all
32
</Directory>
33
34
# Protecting basic directories:
35
<Directory /usr/share/roundcube/config>
36
        Options -FollowSymLinks
37
        AllowOverride None
38
</Directory>
39
40
<Directory /usr/share/roundcube/temp>
41
        Options -FollowSymLinks
42
        AllowOverride None
43
        Order allow,deny
44
        Deny from all
45
</Directory>
46
47
<Directory /usr/share/roundcube/logs>
48
        Options -FollowSymLinks
49
        AllowOverride None
50
        Order allow,deny
51
        Deny from all
52
</Directory>
53

Save and exit vim (Ctrl+C, :wq, Enter) :)

Restart Apache:

systemctl restart apache2.service 

## 1.5. CREATE DB FOR RoundCube

Open MySQL and create DB for RoundCube. Change database name(roundcubemail), username(your DB username) and password to values to match the one you want.

CREATE DATABASE roundcubemail;
GRANT ALL PRIVILEGES ON roundcubemail.* TO [email protected] IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

vim /etc/php5/apache/php.ini

Find:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =

Change and uncomment last line and add time zone.

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone =”Europe/Sarajevo”

(go to http://php.net/manual/en/timezones.php to find the zone you need)

Save vim and exit. Restart Apache

systemctl restart apache2.service

Now, you should be able to open http://192.168.15.83/webmail/installer

(Again, this is my IP, use your own) You should see a lot of OK and a few NOT AVAILABLE (LDAP and available databases)

Configure RoundCube as you desire, based on your needs.

Press CREATE CONFIG on bottom of the 2nd page and follow the instructions.

NOTE: At the end of PHP configuration you need to add “?>” (without quotes), it's missing.

Press CONTINUE button to proceed. Correct any errors reported.

To me, it reported: Check if directories are writable- NOT OK

I solved it with:

chown www-data:www-data {/usr/share/roundcube/temp,/usr/share/roundcube/logs}

Check DB config Press INITIALIZE DATABASE button. Follow the instructions in a red square on the bottom of the page.

CONFIGURING ROUNDCUBE

Create and open main.inc.php:

vim /etc/roundcube/main.inc.php

… and enter line:

$rcmail_config['default_host'] = 'localhost';

NOTE: I was missing both directory “roundcube” and file “main.inc.php”. I created directory (/etc/roundcube) and file within that directory.

My configuration looks like this:

INSTALL ISPConfig3 PLUGIN for RoundCube

cd /tmp
git clone https://github.com/w2c/ispconfig3_roundcube.git
cd /tmp/ispconfig3_roundcube/
mv ispconfig3_* /usr/share/roundcube/plugins
cd /usr/share/roundcube/plugins
mv ispconfig3_account/config/config.inc.php.dist ispconfig3_account/config/config.inc.php

After you complete everything, RoundCube should open from URL http://192.168.15.83/webmail/ NOTE: Log in with the email address and password of an email account you created through ISPConfig

Open ispconfig3_account/config/config.inc.php :

vim ispconfig3_account/config/config.inc.php

… and insert command bellow (or replace values in default configuration):

Change upper values to match your config... Next, configure jquerui plugin in the ISPConfig3 plugins:

vim /etc/roundcube/main.inc.php

Insert:

// ----------------------------------
// PLUGINS
// ----------------------------------
// List of active plugins (in plugins/ directory)
//$rcmail_config['plugins'] = array();
$rcmail_config['plugins'] = array("jqueryui", "ispconfig3_account", "ispconfig3_autoreply", "ispconfig3_pass", "ispconfig3_spam", "ispconfig3_fetchmail", "ispconfig3_filter");

##2. PART 2 - Configure “password change” plugin for RoundCube

By default, “change password” plugin doesn't work.

2.1. Enable “change password” plugin

Go into /usr/share/roundcube/plugins/password and copyconfig.inc.php.dist to config.inc.php

cp /usr/share/roundcube/plugins/password/config.inc.php.dist /usr/share/roundcube/plugins/password/config.inc.php

Open it:

vim config.inc.php

Find line bellow and confirm that it is set to sql:

$config[‘password_driver’] = ‘sql';

If not, set it.

Edit the connector, so that the plugin knows on what database to run the function to change the user's password

NOTE: By default, you run function on dbispconfig. I had to create a new user that has access rights to this DB to modify required fields. I gave that user minimal rights. Then I entered username and password in configuration. I won’t go thru process of creating a user in MySQL (if you stuck here, buzz me :) ).

Find and edit this line:

$config[‘password_db_dsn’] = ‘mysql://username:[email protected]/databasename';

… where you change the username, password and databasename to your installation configuration.

2.2. Create DB function

You can connect to your MySQL and enter these commands or you can do it via PHPMyAdmin. If using PHPMyAdmin, click on dbispconfig database and then click SQL and paste this code and run it.

USE databasename; # Default: dbispconfig
DELIMITER //
CREATE FUNCTION update_passwd (pwd varchar(100), usr varchar(100)) RETURNS INT
BEGIN
UPDATE databasename.mail_user SET password=pwd WHERE login=usr LIMIT 1;
RETURN ROW_COUNT();
END//
DELIMITER ;

Where you change databasename according to your installation configuration

3. Part 3 - ManageSieve server support

Sieve support for Dovecot, allows users to filter incoming messages by writing scripts specified in the Sieve language (RFC 5228). The Pigeonhole ManageSieve service is used to manage a user's Sieve script collection. It has the following advantages over doing it directly via filesystem: The first step is to install the required packages, I assume you got a working set up with Dovecot as imap server, and a working mail client like Roundcube.

Filters are available in RoundCube and you can manipulate received messages the way you want.

3.1. Install the "dovecot-managesieved" package

apt-get install dovecot-managesieved

3.2. Configure Dovecot

Dovecot config files are located in /etc/dovecot/ and there we find dovecot.conf.

Open "/etc/dovecot/dovecot.conf" :

  vim /etc/dovecot/dovecot.conf

and edit it by adding the following things to it, and make sure that the settings match your system:

protocols = [...] sieve

plugin {
[...]
# ispconfig sieve script is loaded before anything else
# this way ispconfig sieve script can be edited by using sive protocol
# if you prefer to keep ispconfig sieve script hidden from using sive protocol
# change location eg. sieve_before = /var/vmail/%d/%n/ispconfig.sieve
sieve_before = /var/vmail/%d/%n/sieve/ispconfig.sieve
sieve_dir = /var/vmail/%d/%n/sieve/
sieve_extensions = +notify +imapflags
# the next to lines are optional but i use them so i show them
# a directory where global .sieve script can be found
sieve_global_dir = /var/vmail/sieve/global
# a global sieve script to use allways
sieve_global_path = /var/vmail/sieve/global/dovecot.sieve
}

service managesieve-login {
inet_listener sieve {
    # port to use for managesieve
    port = 4190
    }
    process_min_avail = 10
    service_count = 1
    vsz_limit = 64 M
    }

    protocol sieve {
    # Explicitly specify the SIEVE and NOTIFY capability reported by the server
    # before login. If left unassigned these will be reported dynamically
    # according to what the Sieve interpreter supports by default (after login this may differ depending on the user).
    # managesieve_notify_capability = mailto
    # managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date ihave imapflags notify
    mail_max_userip_connections = 10
    managesieve_logout_format = bytes=%i/%o
    managesieve_max_compile_errors = 5
    managesieve_max_line_length = 65536
    }
    protocol lda {
    # Make sure sieve i loaded..
    mail_plugins = [...] sieve [...]
    # in this log file all mails will be logged
    log_path = /var/log/sieve.log
    }

Save the file and execute the following commands otherwise you will not receive any e-mails:

touch /var/log/sieve.log && chmod 666 /var/log/sieve.log

Restart Dovecot:

/etc/init.d/dovecot restart

3.3. Checking that dovecot started sieve server

You can check that your conf is working by running following command

netstat -a --numeric-ports | grep 4190

Output should look like bellow:

 tcp        0      0 0.0.0.0:4190            0.0.0.0:*               LISTEN

That should be all!