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

  • MIME support, message searching and spell checking.
  • LDAP directory integration for address books.
  • Support multiple languages.
  • Support for shared/global folders and IMAP ACLs.
  • Built-in caching for fast mailbox access.
  • Support for external SMTP server and IDNA.

Requirements

  • A server running Ubuntu 18.04 LTS.
  • A non-root user with sudo privileges.

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
wget https://github.com/roundcube/roundcubemail/releases/download/1.3.8/roundcubemail-1.3.8-complete.tar.gz

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:

mysql_secure_installation

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)]> FLUSH PRIVILEGES;
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>
        ServerName example.com                          
        ServerAdmin [email protected]
        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
        </Directory>
</VirtualHost>

replace example.com 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.

[email protected]: 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): [email protected]
-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(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?
-------------------------------------------------------------------------------
1: roundcube.example.com
-------------------------------------------------------------------------------
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 roundcube.example.com
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 https://roundcube.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=roundcube.example.com
-------------------------------------------------------------------------------
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/roundcube.example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/roundcube.example.com/privkey.pem
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: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

The RoundCube vhost is accessible by https now.

Access Webmail

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

RoundCube web installer

Web installer - part 2

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

General Configuration:

General configuration

Logging and Database settings:

Database settings

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

SMTP and IMAP settings:

SMTP Settings

IMAP settings

Plugins:

Plugins

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

Create Config

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

Config created

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 http://your-domain.com and sign in using your email.

Roundcube Login

RoundCube has been successfully installed on Ubuntu 18.04 LTS.

Share this page:

Suggested articles

5 Comment(s)

Add comment

Comments

By: Jean-Francois Messier at: 2018-07-27 20:27:49

Just to let you know that in the sudo "apt-get install....." command, there is a typo. You should say "apache2" instead of "apache". Thank You, have a nice day :-)

By: Jean-Francois Messier at: 2018-07-28 16:08:14

You were missing the part where the config.inc.php file must be configured. 

$ cd /var/www/html/toundcube/config

$ cp config.inc.php.sample config.inc.php

$ vi config.inc.php

modify the line starting with "$config['db_dsnw'] = " to update with the appropriate password.  

By: till at: 2019-03-27 17:01:12

That's not missing, the databases settings are configured with the web installer in this tutorial, no need for manual copy and edit of the config file.

By: Luciano at: 2019-01-03 15:49:36

Parabéns pelo tutorial.

Obrigado.

By: Ondrej at: 2019-04-03 12:47:57

My server is up and running, I have already website created - is it safe to follow this tutorial to get mail server? I mean especially if it won't screw up the database in any way. 

Thank you