Roundcube is a free, open-source, browser-based IMAP webmail client with a modern interface. This guide shows how to install it manually from source on Debian 12 (Bookworm), 11 (Bullseye), or 10 (Buster), using Apache2, MariaDB/MySQL, and PHP 8.x.
Step 1: Update System and Install Dependencies
sudo apt update && sudo apt upgrade -y
sudo apt install apache2 mariadb-server php php-mysql php-gd php-xml php-mbstring php-intl php-zip php-curl php-imap php-json php-pear composer unzip wget -y
For Debian 12, PHP is 8.2 by default. For older versions, consider adding Ondřej Surý's PPA if needed for newer PHP.
Step 2: Secure MariaDB and Create Database
sudo mysql_secure_installation
Then create Roundcube database:
sudo mysql -u root -p
CREATE DATABASE roundcube CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'strong_password_here';
GRANT ALL PRIVILEGES ON roundcube.* TO 'roundcube'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 3: Download and Extract Roundcube 1.6.13
cd /tmp
wget https://github.com/roundcube/roundcubemail/releases/download/1.6.13/roundcubemail-1.6.13-complete.tar.gz
tar xzf roundcubemail-1.6.13-complete.tar.gz
sudo mv roundcubemail-1.6.13 /var/www/roundcube
sudo chown -R www-data:www-data /var/www/roundcube
sudo chmod -R 775 /var/www/roundcube/{temp,logs}
Step 4: Import Database Schema
sudo mysql roundcube < /var/www/roundcube/SQL/mysql.initial.sql
Step 5: Configure Apache Virtual Host
Create /etc/apache2/sites-available/roundcube.conf:
<VirtualHost *:80>
ServerName webmail.yourdomain.com
DocumentRoot /var/www/roundcube
<Directory /var/www/roundcube>
Options +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/roundcube_error.log
CustomLog ${APACHE_LOG_DIR}/roundcube_access.log combined
</VirtualHost>
sudo a2ensite roundcube.conf
sudo a2enmod rewrite headers expires deflate
sudo systemctl restart apache2
Step 6: Configure Roundcube
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
Key settings to edit:
$config['db_dsnw'] = 'mysql://roundcube:strong_password_here@localhost/roundcube';
$config['default_host'] = 'ssl://localhost'; // or your IMAP server, e.g. 'ssl://mail.yourdomain.com'
$config['default_port'] = 993;
$config['smtp_server'] = 'tls://localhost'; // or 'tls://mail.yourdomain.com'
$config['smtp_port'] = 587;
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['des_key'] = 'random-24-char-string-here=='; // Generate a secure 24-char key
$config['plugins'] = ['archive', 'zipdownload', 'password', ...]; // Add desired plugins
Step 7: Run the Installer (Browser-Based)
Open in browser: http://webmail.yourdomain.com/installer
- Check environment → Fix any red items.
- Create config → Paste into config.inc.php if needed.
- Initialize database (if not done manually).
- Test IMAP/SMTP connection.
sudo rm -rf /var/www/roundcube/installer
And set $config['enable_installer'] = false; in config.inc.php.
Step 8: Access Roundcube & Final Security
Go to http://webmail.yourdomain.com (or HTTPS) and log in with your email credentials.
- Enable HTTPS with Let's Encrypt:
sudo apt install certbot python3-certbot-apache; sudo certbot --apache - Protect directories: Deny access to
/config,/temp,/logsin .htaccess or vhost. - Update regularly: Watch for security releases like 1.6.13.