How to Install Latest RoundCube Webmail on Ubuntu 18.04 LTS

Roundcube is a free and open source web-based webmail solution written in PHP. It is a web-based IMAP client, so you can also access your email server from your web browser. You don't need to read and send emails from a desktop mail client. This tutorial shows how to install RoundCube with Apache web server and secured by a Let's encrypt SSL certificate on Ubuntu 18.04 LTS (Bionic Beaver).

RoundCube Features


Install LAMP Server

Before starting, you should update the package list and install pending updates:

sudo apt-get update
sudo apt-get upgrade

Then, install Apache and MariaDB with the following command:

sudo apt-get install apache2 mariadb-server php7.2 php7.2-gd php-mysql php7.2-curl php7.2-zip php7.2-ldap php7.2-mbstring php-imagick php7.2-intl php7.2-xml unzip wget curl -y

Once all the packages are installed, you will need to change Timezone setting in php.ini file. You can do this with the following command:

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

Make the following changes:

date.timezone = Europe/Berlin

Save and close the file, then start Apache and MariaDB service and enable them to start on boot time using the following command:

sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl start mariadb
sudo systemctl enable mariadb

Download Roundcube

First, you will need to download the latest version of Roundcube to your system. You can download it with the following command:

cd /tmp

Once the download is completed, extract the downloaded file with the following command:

tar -xvzf roundcubemail-1.3.8-complete.tar.gz

Next, move the extracted directory to the Apache web root directory:

mv roundcubemail-1.3.8 /var/www/html/roundcube

Next, give proper permissions to the roundcube directory:

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

Configure the Database

By default, MariaDB installation is not secured. So you will need to secure it first. You can secure it by running the following script:


Answer all the questions as shown below:

Change the password for root ? N
Remove anonymous users? Y
Disallow root login remotely? Y
Remove test database and access to it? Y
Reload privilege tables now? Y

Once the MariaDB is secured, login to MariaDB shell using the following command:

mysql -u root -p

Enter your root password, then create a database and user for Roundcube:

MariaDB [(none)]> CREATE DATABASE roundcubedb;
MariaDB [(none)]> CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON roundcubedb.* to 'roundcube'@'localhost';

Replace the word 'password' with a secure password of your choice and remember this password, we need it for the roundcube installation later. Next, flush the privileges and exit from the MariaDB shell using the following command:

MariaDB [(none)]> exit;

Next, you need to import initial tables to roundcubedb database. You can do this using the following command:

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

Type in the roundcube database user password when requested.

Configure Apache for Roundcube

Next, you will need to create an Apache virtual host file for Roundcube. You can do this with the following command:

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

Add the following lines:

<VirtualHost *:80>
        DocumentRoot /var/www/html/roundcube

        ErrorLog ${APACHE_LOG_DIR}/roundcube_error.log
        CustomLog ${APACHE_LOG_DIR}/roundcube_access.log combined

        <Directory /var/www/html/roundcube>
                Options -Indexes
                AllowOverride All
                Order allow,deny
                allow from all

replace with your domain name. Save and close the file, then enable virtual host file using the following command:

sudo a2ensite roundcube

Next, enable Apache rewrite module and restart Apache server with the following command:

sudo a2enmod rewrite
sudo systemctl restart apache2

Enable SSL with Let's encrypt for RoundCube

In this step, we will enable SSL for RoundCube by using a free Let's encrypt SSL certificate. The first step is to install the certbot Let's encrypt client which we will use to obtain the SSL certificate.

sudo apt-get install certbot python-certbot-apache

Request the SSL cert with this command:

sudo certbot --apache

IMPORTANT: The domain name or subdomain that you use for the RoundCube website must be accessible from the internet to get an SSL Cert. Certbot will ask a few questions now. See the answers in red.

root@server: certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): youremail@yourdomain.tld
Please read the Terms of Service at You must
agree in order to register with the ACME server at
(A)gree/(C)ancel: a
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
(Y)es/(N)o: n
Which names would you like to activate HTTPS for?
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/roundcube-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/roundcube-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/roundcube-le-ssl.conf
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Redirecting vhost in /etc/apache2/sites-enabled/roundcube.conf to ssl vhost in /etc/apache2/sites-available/roundcube-le-ssl.conf
Congratulations! You have successfully enabled
You should test your configuration at:
- Congratulations! Your certificate and chain have been saved at:
Your key file has been saved at:
Your cert will expire on 2019-06-25. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt:
Donating to EFF:

The RoundCube vhost is accessible by https now.

Access Webmail

Now, open your web browser and type the URL (replace with your domain name in the URL!). You will be redirected to the following page:

Once all the requirements are completed, click on the Next button. You should see the following page:

General Configuration:

Logging and Database settings:

Fill in the database details of the roundcubedb here that you created in the database setup step.

SMTP and IMAP settings:


Here, provide all the details as per your need, then click on the CREATE CONFIG button. You should see the following page:

Next, click on the Continue button. You should see the following page:

Now, click on the Check login button. After completing the installation, remove the directory /var/www/html/roundcube/installer:

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

Now, access your webmail using the URL http://your-ip-address or and sign in using your email.

RoundCube has been successfully installed on Ubuntu 18.04 LTS.

How to Install Latest RoundCube Webmail on Ubuntu 18.04 LTS