Install Roundcube Webmail on VPS Ubuntu

Install Roundcube Webmail on VPS Ubuntu

June 2026 · 8 min read

Roundcube is the most popular webmail client for self-hosted email servers. It lets you access email through a browser just like Gmail, with full support for IMAP/SMTP, seamless integration with Dovecot + Postfix mail stacks, plugin extensibility, customizable skins, and an active community that has maintained it for over 15 years.

Install Dependencies

sudo apt update
sudo apt install nginx php8.1-fpm php8.1-mysql php8.1-curl \
  php8.1-xml php8.1-zip php8.1-mbstring php8.1-intl \
  php8.1-imap mysql-server -y

# Verify
php -v
nginx -v

Create a Database for Roundcube

sudo mysql -u root -p

CREATE DATABASE roundcube CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON roundcube.* TO 'roundcube'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Download and Install Roundcube

# Download Roundcube (check for the latest version at roundcube.net)
cd /tmp
wget https://github.com/roundcube/roundcubemail/releases/download/1.6.7/roundcubemail-1.6.7-complete.tar.gz
tar -xzf roundcubemail-1.6.7-complete.tar.gz
sudo mv roundcubemail-1.6.7 /var/www/roundcube

# Set permissions
sudo chown -R www-data:www-data /var/www/roundcube
sudo chmod -R 755 /var/www/roundcube

Import Database Schema

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

Configure Nginx Virtual Host

sudo nano /etc/nginx/sites-available/roundcube
server {
    listen 80;
    server_name mail.yourdomain.com;
    root /var/www/roundcube;
    index index.php;

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

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    # Block access to sensitive dirs
    location ~ ^/(config|temp|logs) {
        deny all;
    }
}
sudo ln -s /etc/nginx/sites-available/roundcube /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

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
$config['db_dsnw'] = 'mysql://roundcube:StrongPassword123!@localhost/roundcube';
$config['imap_host'] = 'ssl://localhost:993';
$config['smtp_host'] = 'tls://localhost:587';
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['des_key'] = 'your_random_24_char_string_here';
$config['plugins'] = ['archive', 'zipdownload', 'password'];
$config['language'] = 'th_TH';

If you want your own email domain with web hosting, web hosting from asiagb.com offers packages that include email hosting with DirectAdmin at affordable rates starting from just a few hundred baht per year — much easier than managing your own mail server infrastructure. You can also verify your domain's DNS and email configuration using dnsxray.com before setting up Roundcube to ensure your MX records are correct.

Tip: Run the Roundcube installer through your browser for the first time at http://mail.yourdomain.com/installer to verify your configuration and test the database connection before going live. Delete the installer directory immediately afterward.

Verify Roundcube is Working Correctly

# Check PHP-FPM status
systemctl status php8.1-fpm

# Check Nginx error log
sudo tail -f /var/log/nginx/error.log

# Check database connection
mysql -u roundcube -p roundcube -e "SHOW TABLES;"

# Check IMAP connectivity
curl -v imaps://localhost:993 --user [email protected]:password
Tip: After using the installer, delete the installer directory immediately for security: sudo rm -rf /var/www/roundcube/installer. If you don't, Roundcube will display a warning every time you log in.

Common Issues & Troubleshooting

Cannot connect to IMAP server

Check that Dovecot is running and port 993 is open:

systemctl status dovecot
ss -tlnp | grep 993
sudo ufw allow 993/tcp
sudo ufw allow 587/tcp

Can log in but cannot send email (SMTP error)

Check Postfix and verify SMTP credentials in your config:

systemctl status postfix
sudo tail -20 /var/log/mail.log
# Check SMTP configuration in config.inc.php
grep smtp /var/www/roundcube/config/config.inc.php

Database connection failed

Verify credentials and check MySQL service:

systemctl status mysql
mysql -u roundcube -pStrongPassword123! roundcube -e "SELECT 1;"

Roundcube shows "500 Internal Server Error"

Check PHP and Nginx error logs:

sudo tail -50 /var/log/nginx/error.log
sudo tail -50 /var/log/php8.1-fpm.log

# Check that all required PHP extensions are installed
php -m | grep -E "imap|mysql|curl|xml|mbstring"

Frequently Asked Questions

How do Roundcube and Rainloop/Snappymail differ?

Roundcube is a mature project with a large community, comprehensive plugin ecosystem, and excellent documentation. Snappymail (a fork of Rainloop) is lighter and uses more AJAX, making it more responsive on slow connections. For a personal server, Roundcube is better due to its more complete feature set.

Does Roundcube support 2FA?

Yes, through the "Two Factor Authentication" plugin supporting TOTP (Google Authenticator). You can install it from GitHub: github.com/alexandregz/twofactor_gauthenticator, or choose other plugins that support U2F/WebAuthn.

Do I need to set up a mail server before using Roundcube?

Yes, Roundcube is just a webmail client — you need an IMAP server (like Dovecot) and SMTP server (like Postfix) first. Alternatively, you can configure Roundcube to connect to external email providers like Office 365 or Zoho Mail.