Gentoo Wiki


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc



Roundcube is an AJAX (Asynchronous JavaScript and XML) based webmail client. It offers a user-friendly interface and has most of the functionality of a desktop based email client. However, Roundcube is not in portage, and there is sparse documentation for it.

Preparing your System

The dependencies of Roundcube Webmail are:

All of these can be found in portage.


There is an ebuild for Roundcube but it is not officially in portage yet, it is easier to install via the tarballs on the roundcube sourceforge project page (

Download the tarball to your webroot (assuming to be /var/www/localhost/htdocs): tar zxvf roundcubemail-0.1-rc1.tar.gz and change to an easier/shorter URL using mv roundcubemail-0.1beta2 roundcube

Note: In the following, mysql will ask you for a password, default is blank, just hit enter. If your password is blank you should consider adding one with this command: mysqladmin -u root -h localhost password 'pass_goes_here'.

Create the RoundCube database and set up a user.

mysql -u root -p
 create database roundcube;
 grant ALL PRIVILEGES ON roundcube.* TO roundcube@localhost IDENTIFIED BY 'pass_goes_here';
 flush privileges;

Set-up the tables in the database with the file supplied by RoundCube

mysql -u root -p roundcube < /var/www/localhost/htdocs/roundcube/SQL/mysql.initial.sql


Move to the config directory of your RoundCube installation:

cd /var/www/localhost/htdocs/roundcube/config

On a new installation, make a copy of the default config files. The files without .dist will be used as configuration.


Use your favorite editor to change this line in

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['db_dsnw'] = 'mysql://roundcube:pass_goes_here@localhost/roundcube';

Next, edit

Disable caching of mailbox data. It should not be used if RoundCube is on the same server as your IMAP:

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['enable_caching'] = FALSE;

Make sure users are added to the roundcube DB if they have imap accounts(should be default):

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['auto_create_user'] = TRUE;

If you are only using RoundCube for your own mailserver and not using it as a mail client for many accounts then edit this line(putting your mailserver address in place of example):

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['default_host'] = '';

If you need your fully qualified email address to login (usually with Virtual mailbox setups) and are not using multiple Virtual Domain names then edit this line. This way you only need your username and don't have to add

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['username_domain'] = '';

Edit this line to your mailservers address. Otherwise, RoundCube will attempt to use the mail command built into PHP:

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['smtp_server'] = '';

This line should be fine how it is. However, if the mailserver you are trying to use is located outside your network you might need to change this to 587 which is the new standard anyway(or better yet 465 for SSL if supported):

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['smtp_port'] = 25;

Verify users based on SMTP accounts(not default):

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['smtp_user'] = '%u';
$rcmail_config['smtp_pass'] = '%p';

Change the key used to encrypt passwords in the database. Type 24 random characters(ex: fh3$_je2-+EHnf2k:sWE=2a ) in place of the default key supplied. Avoid quotes ' or ":

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['des_key'] = 'rcmail-!24ByteDESkey*Str';

Disable spell check because it sends data to google (do your users want this?!)

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['enable_spellcheck'] = FALSE;

Set the default Timezone(and DST if applicable). Find your UTC/GMT +- offset by clicking on your system clock or search google for time zone( -6 is US Central):

File: /var/www/localhost/htdocs/roundcube/config/
$rcmail_config['timezone'] = -6;
$rcmail_config['dst_active'] = TRUE;

Apache needs the ability to save logs and temp files, and apache should be the owner of files in it's directories:

chown -R apache:apache /var/www/localhost/htdocs/roundcube

And you're all set!

Depending on where you placed the RoundCube directory you should now be able to login to your mail by going to the correct URL. For example: http://localhost/roundcube


Secure (HTTPS) login and URL redirection

This section deals more with Apache set-up then RoundCube. We are also assuming that you have SSL installed properly in apache. Apache Modules mod ssl

Make sure this line is in /etc/conf.d/apache2

File: /etc/conf.d/apache2

You will now need to edit your vhosts file located in /etc/apache2/vhosts.d/ There should be a default file in that directory called 00_default_vhost.conf

If you update Apache it will want to change that file back. If you do not catch the change it will destroy what you have set-up. If you create a separate new vhost file and move the original then you will avoid this problem. After an update you might have to move the 00_default_vhost.conf again but you will not risk losing your edits.

First move the default file. If you every update Apache and then restart it, it will most likely give you an error and you will have to move the original vhost file again.

cd /etc/apache2/vhosts.d/
mv 00_default_vhost.conf

Now create the file you will use. You can copy the original but we will list a default config below for you to copy and paste:

touch vhosts.conf

Edit vhosts.conf with your favorite editor and add the following:

File: /etc/apache2/vhosts.d/vhosts.conf
 NameVirtualHost *
 <VirtualHost *>
    DocumentRoot /var/www/localhost/htdocs/mail-redirect/
 <VirtualHost *>
    DocumentRoot /var/www/localhost/htdocs/main_site/
    ServerAlias *
 NameVirtualHost *:443
 <VirtualHost *:443>
    DocumentRoot /var/www/localhost/htdocs/roundcube/

You can change the directory links such as main_site to what you like. I recommend placing your website(if you have one) in a directory inside the main apache doc folder. You also need to replace to your domainname or IP.

You now need to create the directories you just set up.

mkdir /var/www/localhost/htdocs/mail-redirect
mkdir /var/www/localhost/htdocs/roundcube

Lets first move RoundCube to it's new directory(if it wasn't that to begin with):

cd /var/www/localhost/htdocs/
mv ??path??/roundcube roundcube

Now lets create a redirect.

cd /var/www/localhost/htdocs/mail-redirect/
touch index.html

Edit index.html and add this

File: /var/www/localhost/htdocs/mail-redirect/index.html
     <title>Mail Redirect</title>
     <meta HTTP-EQUIV="Refresh" CONTENT="1;  URL=">
         In 1 second you will be redirected to the secure mail  login.
       <a  href=""></a>

You will need to change to your domain name.

After a /etc/init.d/apache restart you should now be able to go to (replace with your domain) and it will send you to which should be your RoundCube login but now SSL secured.

Retrieved from ""

Last modified: Mon, 08 Sep 2008 22:42:00 +0000 Hits: 13,787