Roundcube

Updated 12 May 2021

Roundcube

Introduction

Roundcube is a Web-based email client written in PHP using JavaScript, CSS, HTML and AJAX. It can be installed on almost any server with PHP version 5.4.0 or higher, and use MySQL, PostgreSQL, SQLite, MSSQL or Oracle Database. It supports IMAP and SMTP mailbox functionality.

Setup of LXC container

We recommend that you install Roundcube in a separate container and configure it as described in the manual.

Installing and configuring Nginx

Install and configure an Nginx webserver and configure PHP-FPM according to the manual.

Configure Nginx for Roundcube. Specify roundcube.example.org as the address:

/etc/nginx/sites-enabled/roundcube.example.org.conf
upstream php-handler {
    server unix:/run/php-fpm.socket;
}

server {
    listen 80;
    server_name roundcube.example.org;
    root /var/calculate/www/roundcube/roundcubemail-latest;
    index index.php index.html index.htm;

    error_log /var/log/nginx/roundcube.error;
    access_log /var/log/nginx/roundcube.access;

    location / {
        try_files $uri $uri/ /index.php;
    }

    location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
        deny all;
    }
    location ~ ^/(bin|SQL)/ {
        deny all;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass php-handler;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi.conf;
    }
}

Installing and configuring PostgreSQL

Install and configure PostgreSQL according to the manual, including password authentication. You need to create user roundcube and database roundcubemail to do this.

Installing and configuring Roundcube

Configure the roundcube user created for PostgreSQL:

mkdir /var/calculate/www

useradd -m -s /sbin/nologin -d /var/calculate/www/roundcube roundcube

Installing Roundcube

Install Roundcube on your webserver:

su - -s /bin/bash roundcube

mkdir versions

VERSION=$(curl -s https://api.github.com/repos/roundcube/roundcubemail/releases/latest | grep tag_name | cut -d '"' -f 4) && echo "Latest RoundCube version is $VERSION"

wget "https://github.com/roundcube/roundcubemail/releases/download/${VERSION}/roundcubemail-${VERSION}-complete.tar.gz" -P versions

tar xf versions/roundcubemail-${VERSION}-complete.tar.gz -C versions

rm versions/roundcubemail-${VERSION}-complete.tar.gz

ln -s versions/roundcubemail-${VERSION} ./roundcubemail-latest

exit

chown -R nginx. /var/calculate/www/roundcube/roundcubemail-latest/{temp,logs}

Using the web interface for configuration

To configure via the Web interface, open http://roundcube.org/installer~ in your browser and do the final Roundcube setup:

Roundcube setup

Specify the connection parameters for the mail server and the database:

Roundcube mail server and database connection setup

Save the resulting configuration file by clicking Save in /tmp:

Roundcube configuration

Copy the settings to /var/calculate/www/example.org/roundcube/config:

cp /tmp/config.inc.php /var/calculate/www/roundcube/roundcubemail-latest/config/config.inc.php

chown roundcube. /var/calculate/www/roundcube/roundcubemail-latest/config/config.inc.php

Once the Roundcube setup is complete, including database initialization, delete folder /var/calculate/www/roundcube/roundcubemail-latest/installer/~, which contains confidential information about server settings:

rm -rf /var/calculate/www/roundcube/roundcubemail-latest/installer

Open http://example.org/roundcube/ in your Web browser. For authentication in Roundcube, use your mailserver login and password:

Roundcube authentication

HTTPS configuration

Getting Let's Encrypt certificate

Get the domain certificate for roundcube.example.org~ for Nginx, according to the manual.

Enabling HTTPS support in Nginx

Configure Nginx to support HTTPS, as described in the manual.

HTTPS configuration for Roundcube

Configure the Nginx service for domain name roundcube.example.org:

/etc/nginx/sites-enabled/roundcube.example.org.conf
upstream php-handler {
    server unix:/run/php-fpm.socket;
}

server {
    listen 80;
    server_name roundcube.example.org;
    rewrite ^ https://$server_name$request_uri? permanent;
}

server {
    listen 443 ssl http2;
    ssl_certificate /etc/letsencrypt/live/roundcube.example.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/roundcube.example.org/privkey.pem;
    include ssl.conf;

    server_name roundcube.example.org;
    root /var/calculate/www/roundcube/roundcubemail-latest;
    index index.php index.html index.htm;

    error_log /var/log/nginx/roundcube.error;
    access_log /var/log/nginx/roundcube.access;

    location / {
        try_files $uri $uri/ /index.php;
    }

    location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
        deny all;
    }
    location ~ ^/(bin|SQL)/ {
        deny all;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass php-handler;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi.conf;
    }
}

Conclusion

Your Roundcube is up and ready to run! Refer to section working_with_roundcube to install and configure the plug-ins.