UbuntuUbuntu Based

How To Install Roundcube on Ubuntu 24.04 LTS

Install Roundcube on Ubuntu 24.04

Roundcube is a modern, browser-based IMAP email client that provides a user-friendly interface similar to desktop email applications. As an open-source solution, it offers robust features including MIME support, address book functionality, and secure communications. For organizations and individuals running mail servers on Ubuntu 24.04 LTS, Roundcube offers an accessible way to manage emails through a web interface.

This comprehensive guide walks you through the complete installation and configuration process of Roundcube on Ubuntu 24.04 LTS, ensuring you have a fully functional webmail solution tailored to your specific requirements.

Table of Contents

Introduction to Roundcube Webmail

Roundcube stands out as one of the most popular open-source webmail clients available today. First released in 2008, it has evolved into a feature-rich application that combines modern technology with user-friendly design. Some of the key features that make Roundcube an excellent choice include:

  • Full MIME and HTML message support for handling various email formats
  • Sophisticated privacy protection mechanisms
  • Intuitive interface with drag-and-drop functionality
  • Multiple sender identity management
  • Comprehensive address book with group support and LDAP integration
  • Rich-text/HTML message composition
  • File attachment handling
  • Advanced message search capabilities
  • Spell-checking functionality

Ubuntu 24.04 LTS (Long Term Support) provides an ideal platform for hosting Roundcube due to its stability, security updates, and long support lifecycle. The combination of Ubuntu’s reliability with Roundcube’s functionality creates an excellent webmail solution for personal or business use.

Prerequisites and System Requirements

Before beginning the installation process, ensure your system meets the following requirements:

Hardware Requirements:

  • Minimum 2GB RAM (4GB recommended for better performance)
  • At least 10GB of free disk space
  • Stable network connection

Software Requirements:

  • Ubuntu 24.04 LTS with root or sudo access
  • Web server (Apache or Nginx)
  • PHP 7.4 or higher with essential extensions
  • Database server (MySQL/MariaDB or PostgreSQL)
  • Mail server with SMTP for sending and IMAP for receiving emails

Domain Configuration:

  • A properly configured domain with DNS settings
  • Ideally, a valid SSL certificate for secure connections

User Permissions:

  • Administrative access to the server
  • Ability to modify web server configurations

Basic Linux command knowledge is essential for following this guide. If you’re new to Linux administration, it might be helpful to familiarize yourself with basic commands before proceeding.

Preparing Your Ubuntu 24.04 LTS System

The first step in any installation process is to prepare your system. This involves updating existing packages and installing essential utilities.

System Updates

Start by updating your package lists and upgrading existing packages:

sudo apt update
sudo apt upgrade -y

This ensures your system has the latest security patches and software versions.

Setting Up Hostname and FQDN

Your mail server should have a proper Fully Qualified Domain Name (FQDN). To check your current hostname:

hostname -f

If you need to update your hostname, use the following commands:

sudo hostnamectl set-hostname mail.example.com

Replace “mail.example.com” with your actual domain. Then, edit the hosts file:

sudo nano /etc/hosts

Add or modify the entry for your server IP:

127.0.0.1 localhost
YOUR_SERVER_IP mail.example.com mail

Configuring System Time

Accurate time is crucial for email operations. Set up Network Time Protocol (NTP):

sudo apt install ntp
sudo systemctl enable ntp
sudo systemctl start ntp

Firewall Configuration

Configure your firewall to allow the necessary ports:

sudo ufw allow 80/tcp    # HTTP
sudo ufw allow 443/tcp   # HTTPS
sudo ufw allow 25/tcp    # SMTP
sudo ufw allow 143/tcp   # IMAP
sudo ufw allow 993/tcp   # IMAPS

Make sure the firewall is enabled:

sudo ufw enable

System Backup

Before proceeding with major changes, it’s advisable to create a backup of your system, especially if you’re working with a production server.

Installing LAMP Stack

The LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) provides the foundation for running Roundcube. Let’s install each component:

Apache Web Server Installation

Install Apache with the following command:

sudo apt install apache2 -y

Enable necessary modules and configure Apache for optimal performance:

sudo a2enmod rewrite
sudo a2enmod ssl
sudo systemctl restart apache2

Verify that Apache is running:

sudo systemctl status apache2

Installing MariaDB Database Server

Install MariaDB:

sudo apt install mariadb-server -y

Secure the installation:

sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, remove test database, and reload privileges.

Installing PHP and Required Extensions

Install PHP and required extensions:

sudo apt install php libapache2-mod-php php-mysql php-json php-xml php-mbstring php-intl php-common php-curl php-gd php-zip -y

Verify PHP installation:

php -v

Configure PHP for optimal performance by editing the php.ini file:

sudo nano /etc/php/*/apache2/php.ini

Update the following parameters:

memory_limit = 128M
upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 300

Restart Apache to apply changes:

sudo systemctl restart apache2

Alternative: Installing LEMP Stack

If you prefer Nginx over Apache, you can install the LEMP stack (Linux, Nginx, MySQL/MariaDB, PHP) instead.

Nginx Web Server Installation

Install Nginx:

sudo apt install nginx -y

Installing MySQL/MariaDB

The database installation remains the same as in the LAMP stack.

Installing PHP-FPM for Nginx

Install PHP-FPM and required extensions:

sudo apt install php-fpm php-mysql php-json php-xml php-mbstring php-intl php-common php-curl php-gd php-zip -y

Configure Nginx to work with PHP-FPM by creating a server block configuration.

Mail Server Configuration

For Roundcube to function properly, you need a mail server that provides SMTP for sending and IMAP for receiving emails.

Installing and Configuring Postfix

Install Postfix:

sudo apt install postfix -y

During installation, select “Internet Site” and enter your fully qualified domain name when prompted.

Configure Postfix by editing the main configuration file:

sudo nano /etc/postfix/main.cf

Update the following parameters:

myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

Installing and Configuring Dovecot

Install Dovecot:

sudo apt install dovecot-imapd dovecot-pop3d -y

Configure Dovecot:

sudo nano /etc/dovecot/conf.d/10-mail.conf

Set the mail location:

mail_location = maildir:/var/mail/vmail/%d/%n

Enable secure IMAP access:

sudo nano /etc/dovecot/conf.d/10-ssl.conf

Set SSL to required:

ssl = required

Restart both services:

sudo systemctl restart postfix
sudo systemctl restart dovecot

Test mail server connectivity before proceeding to ensure everything is configured correctly.

Downloading and Installing Roundcube

Now that we have our LAMP/LEMP stack and mail server configured, we can proceed with installing Roundcube.

Finding and Downloading the Latest Version

Check the latest stable version of Roundcube from the official website or GitHub repository:

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

Note: Replace “1.6.0” with the latest version available at the time of installation.

Extracting and Moving Files

Extract the downloaded archive and move it to the web server directory:

tar -xvzf roundcubemail-1.6.0-complete.tar.gz
sudo mv roundcubemail-1.6.0 /var/www/html/roundcube

Setting Proper Permissions

Set the correct file ownership and permissions:

sudo chown -R www-data:www-data /var/www/html/roundcube
sudo chmod -R 755 /var/www/html/roundcube

Creating the Roundcube Database

Roundcube requires a database to store its configuration and user data.

Creating a MySQL/MariaDB Database

Log in to the MySQL/MariaDB shell:

sudo mysql -u root -p

Create a database and user with appropriate privileges:

CREATE DATABASE roundcubemail;
CREATE USER 'roundcubeuser'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcubeuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Remember to replace ‘strong_password‘ with a secure password.

Web Server Configuration for Roundcube

Configure your web server to serve Roundcube.

Apache Configuration

Create a virtual host configuration file:

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

Add the following configuration:

<VirtualHost *:80>
    ServerName mail.example.com
    DocumentRoot /var/www/html/roundcube
    
    <Directory /var/www/html/roundcube>
        Options -Indexes
        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 restart Apache:

sudo a2ensite roundcube.conf
sudo systemctl restart apache2

Nginx Configuration

If you’re using Nginx, create a server block configuration:

sudo nano /etc/nginx/sites-available/roundcube

Add the following configuration:

server {
    listen 80;
    server_name mail.example.com;
    root /var/www/html/roundcube;
    index index.php;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

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

    location ~ ^/(bin|SQL)/ {
        deny all;
    }
}

Enable the site and restart Nginx:

sudo ln -s /etc/nginx/sites-available/roundcube /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Setting Up SSL/TLS with Let’s Encrypt

For secure communications, install Let’s Encrypt:

sudo apt install certbot python3-certbot-apache -y

For Apache:

sudo certbot --apache -d mail.example.com

For Nginx:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d mail.example.com

Follow the prompts to obtain and install SSL certificates.

Running the Roundcube Web Installer

Now that everything is set up, you can access the Roundcube web installer to complete the configuration.

Accessing the Web Installer

Open your web browser and navigate to:

http://mail.example.com/installer

Install Roundcube on Ubuntu 24.04 LTS

Checking Prerequisites

The installer will check if all prerequisites are met. Ensure everything shows “OK” status before proceeding.

Creating Configuration Files

In the installer, you’ll need to configure several settings:

  1. Database Configuration:
    • Database type: MySQL/MariaDB
    • Database server: localhost
    • Database name: roundcubemail
    • Database user: roundcubeuser
    • Database password: your_password
  2. IMAP Settings:
    • IMAP server: localhost
    • IMAP port: 143 (or 993 for SSL)
    • Default domain: example.com
  3. SMTP Settings:
    • SMTP server: localhost
    • SMTP port: 25 (or 587 for TLS)

Click “Create Config” to generate the configuration file.

Testing Mail Server Connectivity

Use the testing tools provided in the installer to verify:

  • Database connection
  • IMAP connectivity
  • SMTP functionality
  • Test sending and receiving emails

Post-Installation Configuration

After completing the installation, there are several important configuration steps to enhance security and functionality.

Securing the Installation

Remove or disable the installer directory:

sudo rm -rf /var/www/html/roundcube/installer

Or add the following line to the config file:

echo "\$config['enable_installer'] = false;" >> /var/www/html/roundcube/config/config.inc.php

Configuring config.inc.php

Edit the main configuration file to customize Roundcube:

sudo nano /var/www/html/roundcube/config/config.inc.php

Important settings to consider:

// Default mail domain
$config['default_host'] = 'localhost';

// SMTP server settings
$config['smtp_server'] = 'localhost';
$config['smtp_port'] = 25;

// Use secure connections
$config['default_port'] = 993;
$config['default_ssl'] = true;

// Interface language
$config['language'] = 'en_US';

// Specify the timezone
$config['timezone'] = 'UTC';

Setting Default Mail Domain

Configure your default mail domain in the configuration file:

$config['default_host'] = 'mail.example.com';

Customizing User Interface Options

Modify user interface settings according to your preferences:

$config['skin'] = 'elastic'; // Default skin
$config['preview_pane'] = true; // Enable preview pane
$config['login_autocomplete'] = 2; // Enable auto-complete for login form

Installing and Configuring Plugins

Roundcube supports numerous plugins that extend its functionality.

Essential Plugins Overview

Some useful plugins include:

  • password: Allows users to change their passwords
  • managesieve: Enables email filtering rules
  • calendar: Provides calendar functionality
  • archive: Simplifies email archiving

Installing Additional Plugins

To install a plugin:

cd /var/www/html/roundcube/plugins
git clone https://github.com/roundcube/plugin-name.git plugin-name

Enabling and Configuring Plugins

Edit the configuration file to enable plugins:

sudo nano /var/www/html/roundcube/config/config.inc.php

Add the plugin to the plugins array:

$config['plugins'] = array('password', 'managesieve', 'calendar');

Security Hardening

Enhancing security is crucial for any web application, especially one handling email data.

Implementing HTTPS with Strong Ciphers

Ensure your SSL configuration uses strong ciphers:

sudo nano /etc/apache2/mods-available/ssl.conf

Add the following configuration:

SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite HIGH:!aNULL:!MD5:!3DES
SSLHonorCipherOrder on

Securing PHP Configuration

Edit the php.ini file:

sudo nano /etc/php/*/apache2/php.ini

Update security settings:

expose_php = Off
display_errors = Off
display_startup_errors = Off
log_errors = On
allow_url_fopen = Off

Implementing Fail2ban Protection

Install Fail2ban to protect against brute force attacks:

sudo apt install fail2ban -y
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local

Add a configuration for Roundcube:

[roundcube]
enabled = true
port = http,https
filter = roundcube
logpath = /var/log/apache2/roundcube_error.log
maxretry = 5
bantime = 3600

Create a filter:

sudo nano /etc/fail2ban/filter.d/roundcube.conf

Add the following:

[Definition]
failregex = FAILED login for .* from <HOST>
ignoreregex =

Restart Fail2ban:

sudo systemctl restart fail2ban

Testing the Complete Installation

Before considering the installation complete, it’s essential to test all functionality.

Testing User Login

Access your Roundcube installation through a web browser and verify that login works with valid credentials.

Sending and Receiving Test Emails

Send test emails to internal and external addresses and verify receipt.

Testing Attachments and Address Book

Upload file attachments and check if they are properly handled.
Add contacts to the address book and test search functionality.

Troubleshooting Common Issues

Despite careful installation, issues can arise. Here are solutions to common problems.

Database Connection Problems

If you encounter database connection issues:

  • Verify database credentials in config.inc.php
  • Check if the database server is running
  • Ensure the user has proper permissions
sudo systemctl status mysql
mysql -u roundcubeuser -p -D roundcubemail

IMAP/SMTP Connectivity Issues

For mail server connection problems:

  • Check if the mail services are running
  • Verify correct hostnames and ports
  • Test connectivity using telnet
sudo systemctl status dovecot
sudo systemctl status postfix
telnet localhost 143
telnet localhost 25

PHP Configuration Errors

If PHP errors occur:

  • Check PHP error logs
  • Verify all required extensions are installed
  • Ensure PHP version compatibility
sudo tail -f /var/log/apache2/error.log
php -m

Maintenance and Updates

Regular maintenance ensures your Roundcube installation remains secure and performs optimally.

Creating Regular Backup Routines

Set up regular backups of your Roundcube database and configuration:

mysqldump -u root -p roundcubemail > /backup/roundcube_$(date +%F).sql
cp -r /var/www/html/roundcube/config /backup/roundcube_config_$(date +%F)

Updating Roundcube Safely

To update Roundcube to a newer version:

  1. Backup your current installation
  2. Download the new version
  3. Replace the files while preserving your configuration
  4. Run the update script if provided
cd /tmp
wget https://github.com/roundcube/roundcubemail/releases/download/VERSION/roundcubemail-VERSION-complete.tar.gz
tar -xvzf roundcubemail-VERSION-complete.tar.gz
sudo cp -r /var/www/html/roundcube/config /tmp/config_backup
sudo rm -rf /var/www/html/roundcube
sudo mv roundcubemail-VERSION /var/www/html/roundcube
sudo cp -r /tmp/config_backup/* /var/www/html/roundcube/config/
sudo chown -R www-data:www-data /var/www/html/roundcube

Database Maintenance Tasks

Regularly optimize your database for better performance:

mysql -u root -p -e "OPTIMIZE TABLE roundcubemail.users, roundcubemail.contacts, roundcubemail.identities;"

Congratulations! You have successfully installed Roundcube. Thanks for using this tutorial for installing the Roundcube webmail on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Roundcube website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button