Thursday, November 26, 2015

Roundcube webmail with SQLite on Debian

Roundcube is not available through apt-get in Debian 8 (Jessie), and the version which is in Debian 7 (Wheezy) is outdated. However, installing directly from the source is very easy.

I used SQLite, because these servers will only occasionally serve a few users for single domains. So a full database server seemed overkill. I selected /opt/roundcube as my install dir.

mkdir $rcdir
cd $rcdir

Check the latest version on the "Roundcube Webmail Downloads". As of November 2015, the version was 1.1.3. Copy the link for the "Complete" download.


Uncompress, copy out of the version-specific folder, and rename the original folder in case you need it.

tar xvf roundcubemail-$version-complete.tar.gz
rm roundcubemail-$version-complete.tar.gz
cp -rp roundcubemail-$version/* ./
mv roundcubemail-$version roundcubemail-$version.orig

Install dependencies

apt-get install php5 php-pear php5-sqlite

Initialize database

mkdir db
sqlite3 -init SQL/sqlite.initial.sql db/roundcube.sqlite

You will be left at the sqlite prompt. Type ".quit".

# sqlite3 -init SQL/sqlite.initial.sql db/roundcube.sqlite
 -- Loading resources from SQL/sqlite.initial.sql

 SQLite version 3.7.13 2012-06-11 02:05:22
 Enter ".help" for instructions
 Enter SQL statements terminated with a ";"
 sqlite> .quit

Set permissions

chown -R www-data:www-data temp logs db
chmod -R 775 db
Edit the Apache config file with your favorite editor. (I suggest mcedit or nano)
$EDITOR /etc/apache2/sites-available/webmail.conf

<VirtualHost *:80>
  RedirectPermanent /

<VirtualHost *:443>

  SSLEngine on
  SSLProtocol all -SSLv2 -SSLv3
  SSLCACertificateFile   /etc/ssl/example.com_selfsigned_CA.pem
  SSLCertificateFile     /etc/ssl/example.com_web.pem
  SSLCertificateKeyFile  /etc/ssl/private/example.com_web.key


  DocumentRoot /opt/roundcube

  CustomLog /var/log/apache2/roundcube-access.log combined3

  <Directory /opt/roundcube/>
    Options +FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

  <Directory /opt/roundcube/config>
    Options -FollowSymLinks
    AllowOverride None

  <Directory /opt/roundcube/temp>
    Options -FollowSymLinks
    AllowOverride None
    Order allow,deny
    Deny from all

  <Directory /opt/roundcube/logs>
    Options -FollowSymLinks
    AllowOverride None
    Order allow,deny
    Deny from all

You may also need to add NameVirtualHost *:443 to /etc/apache2/ports.conf

Check the Apache config. and reload

a2ensite webmail
apache2ctl -S
apache2ctl graceful

Edit the Roundcube config file.

cd $rcdir/config
cp -pf

Change these:

$config['db_dsnw'] = 'sqlite:////opt/roundcube/db/roundcube.sqlite?mode=0646';
  $config['smtp_server'] = 'localhost';

And add this:

$config['mail_domain'] = '%d'; # let new users get the right domain instead of the default "user@localhost"

If needed, see also the Roundcube Wiki.


Post a Comment

Links to this post:

Create a Link

<< Home