Install and Configure Roundcube Webmail on Ubuntu 26.04

This is the last part of the Setting up and configuring a mail server series. After Postfix, Dovecot, and Rspamd are working, Roundcube gives users a browser-based mailbox interface.
Roundcube is a web-based IMAP email client written in PHP. To use Roundcube, you only need a web browser.
Roundcube includes all the features you need in an email client, such as rich text and HTML message composing, an address book, MIME and HTML email support, multiple sender identities, spell checking, a three-column view, drag and drop message management, and more.
Prerequisites
Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges and that you have completed the first , second , and third parts of the series. By the end of the third part you will have a working PostfixAdmin instance, Postfix and Dovecot configured for virtual users, and Rspamd scanning and signing mail.
PHP dependencies
Install all required PHP extensions for Roundcube 1.6:
sudo apt update
sudo apt install -y php-fpm php-cli php-mysql php-mbstring php-intl php-xml php-curl php-zip php-gd php-ldap php-imagickOnce the installation is completed, run the following sed
command to set the date.timezone value to UTC. The Ubuntu 26.04 PHP-FPM configuration directory is named after the active PHP branch, so the path may include 8.5 or another version, depending on what is installed:
PHP_INI=$(php -r 'echo php_ini_loaded_file();' | sed 's|/cli/|/fpm/|')
sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" "$PHP_INI"Restart the PHP-FPM service for the changes to take effect:
sudo systemctl restart "$(systemctl list-units 'php*-fpm.service' --no-legend --plain | awk '{print $1; exit}')"Create MySQL Database
Roundcube supports MySQL , PostgreSQL , and SQLite database backends.
In this tutorial we will use MySQL as our database server. Log in to the MySQL shell :
sudo mysqlCreate a new MySQL database , a user, and grant privileges to that user over the new database:
CREATE DATABASE roundcubemail CHARACTER SET utf8mb4;
CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'roundcube_db_password';
GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcube'@'localhost';
FLUSH PRIVILEGES;
EXIT;roundcube_db_password with a long random password. Do not commit the real password or the generated des_key value to version control.Download Roundcube
At the time of writing, 1.6.15 is the latest stable version of Roundcube. Before continuing, check the Roundcube download page
to see if a newer version is available.
Download the Roundcube complete tarball using the following wget command
. The complete tarball already bundles the JavaScript dependencies (TinyMCE and friends), so you do not need to run bin/install-jsdeps.sh later:
cd /tmp
wget https://github.com/roundcube/roundcubemail/releases/download/1.6.15/roundcubemail-1.6.15-complete.tar.gzOnce the download completes, extract the archive
and move
the Roundcube source files to the /var/www/roundcubemail directory:
tar xzf roundcubemail-1.6.15-complete.tar.gz
sudo mv roundcubemail-1.6.15 /var/www/roundcubemailNginx and PHP-FPM are running as the www-data user, so we need to change the ownership of the Roundcube directory to that user:
sudo chown -R www-data:www-data /var/www/roundcubemailImport the Roundcube database schema with the MySQL CLI so we can skip the web installer entirely:
mysql -u roundcube -p roundcubemail < /var/www/roundcubemail/SQL/mysql.initial.sqlConfigure Roundcube
Copy the sample configuration file to a working config.inc.php and open it in your text editor:
sudo cp /var/www/roundcubemail/config/config.inc.php.sample /var/www/roundcubemail/config/config.inc.php
sudo nano /var/www/roundcubemail/config/config.inc.phpGenerate a 24-character des_key value, which Roundcube uses to encrypt session data:
openssl rand -base64 18Set the following values, replacing replace_with_24_character_random_key with the value you just generated:
$config['db_dsnw'] = 'mysql://roundcube:roundcube_db_password@localhost/roundcubemail';
$config['imap_host'] = 'ssl://mail.linuxize.com:993';
$config['smtp_host'] = 'tls://mail.linuxize.com:587';
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['support_url'] = '';
$config['product_name'] = 'Linuxize Mail';
$config['des_key'] = 'replace_with_24_character_random_key';
$config['plugins'] = ['archive', 'zipdownload', 'managesieve'];
$config['managesieve_host'] = 'localhost';
$config['managesieve_port'] = 4190;The managesieve plugin enables a server-side filter editor in the Roundcube UI. The filters are stored on Dovecot through the managesieve protocol on port 4190, which we already enabled in the second part
of this series.
Configure Nginx
Roundcube 1.6 uses public_html/ as its web root. Rather than serving Roundcube as an alias path under the PostfixAdmin server block, we will create a dedicated webmail.linuxize.com server block. The dedicated subdomain keeps the Roundcube configuration self-contained and avoids the alias plus try_files plus PHP location interaction that breaks alias-based setups.
Make sure you have an A record for webmail.linuxize.com pointing at the same IP address as mail.linuxize.com, then issue a Let’s Encrypt certificate for the new hostname:
sudo certbot --nginx -d webmail.linuxize.comCreate the server block:
sudo nano /etc/nginx/sites-available/webmail.linuxize.comPaste the following configuration:
server {
listen 80;
server_name webmail.linuxize.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name webmail.linuxize.com;
ssl_certificate /etc/letsencrypt/live/webmail.linuxize.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/webmail.linuxize.com/privkey.pem;
root /var/www/roundcubemail/public_html;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING|bin|SQL|config|temp|logs)(/|$) {
deny all;
}
location ~ /\. {
deny all;
}
}If /run/php/php-fpm.sock does not exist on your system, replace it with the versioned path you saw earlier in the series, for example /run/php/php8.5-fpm.sock.
Enable the site, test the configuration, and reload Nginx :
sudo ln -s /etc/nginx/sites-available/webmail.linuxize.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxVerify your Roundcube Installation
Open https://webmail.linuxize.com/ in your web browser and log in using the email account you created in PostfixAdmin.

Once the inbox loads, send a test message to another mailbox on your domain, and reply to it from a different account, to confirm that both inbound and outbound flows work through Roundcube.

Troubleshooting
Roundcube login fails
Check the Roundcube and mail logs for the cause:
sudo tail -n 100 /var/www/roundcubemail/logs/errors.log
sudo tail -n 100 /var/log/mail.log
sudo journalctl -u dovecot -n 100 --no-pager
sudo journalctl -u postfix -n 100 --no-pagerNginx returns 502 Bad Gateway
The fastcgi_pass socket probably does not match the running PHP-FPM service. Check the active socket and update the Roundcube server block if needed:
ls -l /run/php/
systemctl list-units 'php*-fpm.service'Create your first Sieve filter
With the managesieve plugin enabled, Roundcube users can manage server-side mail filters from the web interface. Sieve filters run on the Dovecot LMTP path during local delivery, so they apply to every device that connects to the mailbox, not only to Roundcube.
To create a filter that moves messages flagged as spam by Rspamd into the Junk folder, open Roundcube and go to Settings, then Filters, then click Create. Use a filter definition similar to this:
require ["fileinto"];
if header :contains "X-Spam" "Yes" {
fileinto "Junk";
stop;
}Save the filter as the active script. Roundcube will store it through the managesieve protocol, and Dovecot LMTP will apply it the next time a message arrives. Send a known spam test from outside your domain to confirm that the message lands in Junk instead of the inbox.
Conclusion
You have installed Roundcube on Ubuntu 26.04, served it from a dedicated webmail.linuxize.com subdomain over HTTPS, imported the database schema directly with the MySQL CLI, and configured the managesieve plugin so users can manage their own server-side filters.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page