The Best Price for IPv4/IPv6 Lease – Any RIR & Any Geo-LocationOrder Now
Hostperl

Setup Roundcube Webmail on Ubuntu VPS: Complete IMAP Integration

By Raman Kumar

Share:

Updated on Jun 2, 2026

Setup Roundcube Webmail on Ubuntu VPS: Complete IMAP Integration

Requirements and Prerequisites

You'll need a running Ubuntu VPS with Apache or Nginx, plus MySQL or MariaDB. Your server should have at least 1GB RAM and enough disk space for email storage.

A working IMAP server like Dovecot must already be configured and accepting connections. Make sure your server has a fully qualified domain name pointing to it. You'll also need root or sudo access to install packages and configure services.

For customers using Hostperl VPS hosting, these requirements are typically pre-configured, making the setup process much smoother.

Download and Install Roundcube

Start by updating your package list and installing required dependencies:

sudo apt update
sudo apt install wget unzip php php-mysql php-mbstring php-intl php-xml php-zip php-curl php-gd

Download the latest Roundcube release from the official website:

cd /tmp
wget https://github.com/roundcube/roundcubemail/releases/download/1.6.5/roundcubemail-1.6.5-complete.tar.gz
tar -xzf roundcubemail-1.6.5-complete.tar.gz

Move the extracted files to your web server directory:

sudo mv roundcubemail-1.6.5 /var/www/roundcube
sudo chown -R www-data:www-data /var/www/roundcube

Set appropriate permissions for security:

sudo chmod -R 755 /var/www/roundcube
sudo chmod -R 777 /var/www/roundcube/temp /var/www/roundcube/logs

Database Configuration Setup

Create a dedicated MySQL database and user for Roundcube. Log into MySQL as root:

sudo mysql -u root -p

Run these SQL commands to create the database and user:

CREATE DATABASE roundcube DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON roundcube.* TO 'roundcube'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Import the Roundcube database schema:

sudo mysql -u roundcube -p roundcube < /var/www/roundcube/SQL/mysql.initial.sql

This creates all necessary tables for user authentication, contacts, and email metadata.

Apache Virtual Host Configuration

Create a new Apache virtual host configuration for your Roundcube installation:

sudo nano /etc/apache2/sites-available/roundcube.conf

Add this configuration. Replace your-domain.com with your actual domain:

<VirtualHost *:80>
    ServerName webmail.your-domain.com
    DocumentRoot /var/www/roundcube
    
    <Directory /var/www/roundcube>
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog ${APACHE_LOG_DIR}/roundcube_error.log
    CustomLog ${APACHE_LOG_DIR}/roundcube_access.log combined
</VirtualHost>

Enable the site and required Apache modules:

sudo a2ensite roundcube.conf
sudo a2enmod rewrite
sudo systemctl reload apache2

Setup Roundcube Webmail on Ubuntu VPS Main Configuration

Copy the sample configuration file and modify it for your setup:

sudo cp /var/www/roundcube/config/config.inc.php.sample /var/www/roundcube/config/config.inc.php
sudo nano /var/www/roundcube/config/config.inc.php

Configure the database connection by finding and updating this line:

$config['db_dsnw'] = 'mysql://roundcube:your_secure_password@localhost/roundcube';

Set your IMAP server configuration:

$config['default_host'] = 'localhost';
$config['default_port'] = 143;
$config['imap_conn_options'] = array(
    'ssl' => array(
        'verify_peer'  => false,
        'verify_peer_name' => false,
    ),
);

Configure SMTP settings for sending emails:

$config['smtp_server'] = 'localhost';
$config['smtp_port'] = 587;
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';

IMAP Server Integration

Verify your Dovecot IMAP service is running and configured properly:

sudo systemctl status dovecot
sudo netstat -tlnp | grep :143

Test IMAP connectivity from localhost:

telnet localhost 143

You should see a response like "* OK [CAPABILITY...] Dovecot ready." If this fails, check your mail server configuration before proceeding.

Update Roundcube's IMAP configuration to match your Dovecot setup:

$config['imap_timeout'] = 300;
$config['imap_auth_type'] = 'LOGIN';
$config['imap_delimiter'] = '.';

SSL Certificate Setup

Secure your webmail interface with SSL using Let's Encrypt:

sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d webmail.your-domain.com

This automatically configures Apache with SSL and redirects HTTP traffic to HTTPS. Your virtual host gets updated with SSL directives.

Test the SSL configuration:

sudo apache2ctl configtest
sudo systemctl reload apache2

For comprehensive SSL certificate management across your hosting environment, consider automating renewals and monitoring expiry dates.

User Authentication Configuration

Configure Roundcube to authenticate users against your system's user database. Modify these authentication settings in the config file:

$config['login_autocomplete'] = 2;
$config['auto_create_user'] = true;
$config['username_domain'] = 'your-domain.com';

Set up password policies and user preferences:

$config['password_charset'] = 'UTF-8';
$config['password_algorithm'] = 'clear';
$config['dont_override'] = array('default_host');

Test user authentication by logging in through the web interface with an existing email account.

Plugin Installation and Configuration

Enable useful plugins by editing the plugins array in your configuration:

$config['plugins'] = array(
    'archive',
    'zipdownload',
    'password',
    'managesieve',
    'markasjunk'
);

Configure the password plugin to allow users to change their passwords:

sudo cp /var/www/roundcube/plugins/password/config.inc.php.dist /var/www/roundcube/plugins/password/config.inc.php
sudo nano /var/www/roundcube/plugins/password/config.inc.php

Update the password driver configuration:

$config['password_driver'] = 'sql';
$config['password_db_dsn'] = 'mysql://roundcube:your_password@localhost/roundcube';

Performance Optimization

Optimize Roundcube for better performance with these configuration tweaks:

$config['enable_caching'] = true;
$config['message_cache_lifetime'] = '10d';
$config['messages_cache_threshold'] = 50;

Enable compression and optimize database queries:

$config['compress_responses'] = true;
$config['db_max_length'] = 512000;

Configure session handling for improved security:

$config['session_lifetime'] = 20;
$config['session_domain'] = '.your-domain.com';

Monitor your webmail performance. Consider implementing database optimization techniques for larger user bases.

Backup and Maintenance Procedures

Set up automated backups for your Roundcube installation and user data:

#!/bin/bash
mysqldump -u roundcube -p roundcube > /backup/roundcube-$(date +%Y%m%d).sql
tar -czf /backup/roundcube-files-$(date +%Y%m%d).tar.gz /var/www/roundcube

Create a cron job to run backups daily:

sudo crontab -e
# Add this line:
0 2 * * * /usr/local/bin/backup-roundcube.sh

Regular maintenance includes updating Roundcube, monitoring log files, and cleaning up temporary files:

sudo find /var/www/roundcube/temp -type f -mtime +7 -delete
sudo find /var/www/roundcube/logs -name "*.log" -mtime +30 -delete

Ready to deploy professional webmail hosting? Hostperl VPS hosting provides the reliable infrastructure and support you need for mail server deployments. Our New Zealand-based team helps customers with complex email hosting setups and migrations.

Frequently Asked Questions

Can I use Roundcube with external IMAP servers like Gmail?

Yes, configure the IMAP settings to point to external servers like imap.gmail.com on port 993 with SSL enabled. Users can then access their external email accounts through your Roundcube installation.

How do I troubleshoot IMAP connection failures?

Check the Roundcube logs in /var/www/roundcube/logs/errors and verify your IMAP server is running with netstat -tlnp | grep :143. Make sure firewall rules allow connections on the IMAP port.

What's the recommended way to upgrade Roundcube?

Download the new version, backup your configuration and database, replace the files while preserving the config directory, then run any required database update scripts from the SQL directory.

How can I customize the Roundcube interface for my organization?

Modify the skins directory to customize themes, update the main.inc.php configuration for branding, and use plugins to add custom functionality specific to your business needs.

Is it safe to allow users to change passwords through Roundcube?

Yes, when properly configured with the password plugin and appropriate backend drivers. Make sure you're using secure password policies and SSL encryption for all password change operations.