Installing a Roundcube webmail in less than 30 minutes

Since the last time I installed machine (from scratch), I did not have any webmail back in place. I used to work with horde, a well known webmail framework. It is certainly very powerful, but I use the webmail very sparsely, when I cannot use ssh to access my machine. It is also quite complicated to install.

Last wednesday, or the week before, I found myself cornered in such a situation. The webmail offered at my lab was not enough (I wanted to read a specific mailbox on another server). This morning, I resolved to scratch this itch. I managed to do it in less than 30 minutes, without having read any documentation (I had just browsed the screenshots on the software's website). Congratulations for the good work to Roundcube!

The menu :

  • The day before, prepare a specific hostname for the webmail (I quite like one name = one service) (e.g. webmail.mondomaine.fr). Let it infuse one whole night.
  • Create a virtual host. Over time, I came to make a script that does most of the hard work for me (including registering it in awstats). Do it again once you see that you forgot to make it as root, and clean the mess.
  • Edit the virtual host so that SSL is used (https), because passwords are going through this canal. Activate PHP5 for this host (I like FastCGI, I do not use PHP all the time, so it's less cumbersome in memory, and lets you use the efficient apache daemons).
  • Generate a certificate accepting the new name webmail.mondomaine.fr.
  • Restart Apache. Check that a random file in the root of the new domain can be seen.
  • sudo aptitude install roundcube and follow the instructions. You will be asked for the password of your database (if using MySQL, at least).
  • Loiter five minutes there to be sure of what is to be done. Go to the root of the new comain, and do a for i in /var/lib/roundcube/*; do ln -s $i; done. Copy a PHP5 fcgi launching file from somewhere else.
  • Point your browser at https://webmail.mondomaine.fr/. Test a first connection. See that the connection is not done over SSL, and that external servers therefore refuse to speak with you.
  • Change a line of config/main.inc.php to have instead $rcmail_config['default_host'] = array('ssl://monimap.mondomaine.fr','ssl://mail.monboulot.fr','ssl://monautreserveur.fr');. Let it cool, it's ready.

Here is the final file in /etc/apache2/sites-available/webmail.mondomaine.fr and the one to launch FCGI just below:

<virtualHost *:443="">
DocumentRoot /var/www/webmail.mondomaine.fr/
ServerName webmail.mondomaine.fr
ErrorLog /var/log/apache2/webmail.mondomaine.fr/error.log
CustomLog /var/log/apache2/webmail.mondomaine.fr/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/oberon.mondomaine.fr.crt
SSLCertificateKeyFile /etc/apache2/ssl/oberon.mondomaine.fr.key
ServerAdmin
AddDefaultCharset utf-8
DirectoryIndex index.html index.php
# Uncomment to use PHP5
AddHandler fastcgi-script .fcgi
AddHandler php-fastcgi .php
AddHandler php5-fastcgi .php5
Action php-fastcgi /php5-wrapper.fcgi
Action php5-fastcgi /php5-wrapper.fcgi
</virtualHost>

#!/bin/dash
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=1000
export PHP_FCGI_MAX_REQUESTS
exec /usr/bin/php5-cgi

[Edit]: I also add to modify another line to get $rcmail_config['create_default_folders'] = TRUE;. Without this, I could not delete my messages!

None
A comma-separated list of terms describing this content. Example: funny, bungee jumping, "Company, Inc.".