How to Install Roundcube Webmail on Ubuntu16.04

Roundcube is a web application which can be used to access your emails from a web browser. It is a free and open source software tool by Roundcube Webmail project. It has a clean user interface and provides many features like full support for MIME and HTML messages, multilingual capabilities (70+ languages), find-as-you-type address book, threaded message listing, spell checking and many more. Recently, Roundcube version 1.2 has been released and in this article, let us learn how to install and configure the same on Ubuntu 16.04.


Before going ahead with Roundcube installation, we need to first install LAMP (Linux, Apache, MySQL and PHP) packages.

sudo apt-get install lamp-server^

Creating MySQL Database and User

Login to MySQL as root and create a new MySQL database. Here I'm creating one by name roundcubedb and assigning a password.

mysql -u root -p
tester@BNPTHKPD:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.12-0ubuntu1 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database 'roundcubedb';
Query OK, 1 row affected (0.00 sec)
mysql> create user 'mailadmin' identified by 'mailadmin';
Query OK, 0 rows affected (0.00 sec)

Let us now grant complete access to the 'roundcubedb' to this new user 'mailadmin'.

mysql> grant all privileges on roundcubedb.* to 'mailadmin';
Query OK, 0 rows affected (0.00 sec)

Flush the privilege table and exit from MySQL command prompt

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Install Roundcube webmail

We will now download and install the latest version (v1.2) of Roundcube from github.

tester@BNPTHKPD:~$ cd /tmp && wget
--2016-06-20 13:30:22--

The above command creates a tmp directory under / and downloads the roundcubemail-1.2.0 tar file into it.

Let us extract the archive into /var/www/webmail directory

tester@BNPTHKPD:/tmp$ sudo tar -xzvf roundcoubemail-1.2.0-complete.tar.gz -C /var/www
tester@BNPTHKPD:/tmp$ sudo mv /var/www/roundcubemail-1.2.0/ /var/www/webmail

Change the ownership of '/var/www/webmail' to  'www-data' which is the user and group web server.

sudo chown -R www-data:www-data /var/www/webmail/*

sudo chown -R www-data:www-data /var/www/webmail/

Import the roundcubedb database into MySQL server and login to the server.

mysql -u root -p roundcubedb < /var/www/webmail/SQL/mysql.initial.sql

In order to start the installation, open the web browser (chrome / firefox) and type the following into the address bar:


It pops up the following page:

Roundcube installer screen

This checks if all the required extensions, modules and databases are installed properly. Take a look at it carefully and install the ones against which you find 'NOT OK' or 'NOT AVAILABLE'. In some cases, only one of them will be required and not all. Hence, following the instructions carefully on this page is important.

Click on the 'Next' button.  It will take you to the configuration page. Here we need to fill in the MySQL database details that we created a while ago. If we want to access other mail accounts from Roundcube like Gmail , we need to also fill in the SMTP and IMAP settings in this page. Settings for gmail SMTP and IMAP are found google page.

MySQL DB setup

SMTP settings

SMTP settings

After the setup is complete, press the 'Create Config' button which will result in saving the configuration file to /var/www/webmail/config/

Roundcube config successful

When we press the 'Continue' button, we will be led do the Test config screen. Here one can optionally test if we are able to send and receive mails to and from the mail server.

This completes the configuration of Roundcube. Now remove the directory /var/www/webmail/installer for security reasons.

sudo rm -rf /var/www/webmail/installer

Roundcube webmail is now ready to be used. Point the browser to  http://localhost/webmail. Login screen appears. Sign in using the account for which you have configured Roundcube and you are ready to go!

If all your settings are correct, but you are still facing trouble in logging into your gmail account from Roundcube, here is what you need to check. Login to gmail from a web browser. Go to 'settings' and in the 'Forwarding and POP/IMAP' tab under 'IMAP access', enable the radio button 'Enable IMAP'.

If this still doesn't solve the problem, check if 'Access for less secure apps' is turned ON in the google settings.

Turning on SecureApps settings

Here comes the Roundcube inbox screen once you login.

Roundcube inbox

Upgrading from previous versions

If you are on a previous version of roundcube and want to upgrade to the latest version, backup the existing installation and database first.  Now, go to /var/www/webmail/bin directory and execute the ''  script present there in the following way:  <target-folder>

Here, 'target-folder' is the path to the Roundcube installation that needs to be updated.  For more details and post-update activities, refer to the 'UPGRADING' file under /var/www/webmail directory.


In this tutorial, we have learnt how to install and configure Roundcube webmail on Ubuntu 16.04.  You can also add some additional plugins to extend its functionality and customize it. Go ahead and give it a try.

B N Poornima 3:00 am


Your email address will not be published. Required fields are marked *


  1. I have gone through this twice now, but keep getting a problem at the test stage. It keeps saying that the file is unreadable.

    There is an error in the instructions, the location of the config file has to be /var/www/html/webmail/config ... (its missing the html part) then it reads fine ...

    1. Chris, first of all, thanks for choosing linoxide for your needs! I have cross checked the configuration files and the location that is mentioned in the tutorial is correct. It is '/var/www/webmail/config'.

      BNPTHKPD:/var/www/webmail/config$ ls mimetypes.php

      The /var/www/html directory contains only a single index file and nothing else.
      During the 'Create Config' phase, did you get a message saying that the config file was saved successfully, as mentioned in the tutorial?
      If you can let me know what exactly you are trying to do during the test phase, I can help you out.

        1. Hi,
          Please check the 'Install Roundcube webmail' section. Here, when you open the installer in the browser, it opens a setup page which has the 'Create Config' button at the end of it.

  2. Yep, went through everything as described. It all worked fine, but it didn't. When I copied the files as described above to the revised location, it worked prefectly ... no other change was made. Weired

    I have no explanation unless the copy of Ubuntu server was changed slightly in its sub revision. Anyway, if anyone has a similar problem, they could try that. I can't recall what tipped me off to go look at the /var/www/html/webmail location, it was something ... I think I was reading something somewhere else relating to the webserver paths.

    To err is human, to really stuff it up you need a computer :-)

  3. Perhaps I should also say for clarity, that all the files were correctly created in teh directories stated in the guide, they just would not serve up. All I did to get everything working was copy the files to the /var/www/html/webmail/config directory. Not additional change at all, then everything worked prefectly ...

  4. Hi guys,
    all installation is fine, but when I want to login with username and password I'm receiving messange "connection to the storage failed"
    Can you help me with ?

    1. Hi Ladis,
      1. Can you please check the file /var/www/webmail/logs/errors and see if there are more details regarding this error message?
      2. Run the installer and try the IMAP connection test in the test config section and see if it is successful. If not, provide the error message

  5. What am I missing: if I use w3m to open localhost/webmail/installer I get a 404. I would think apache does not know yet where to find roundcube. Am I missing a step that is obvious for others?

    1. Ok, I added a conf file for apache and now I get to the installer. I was hoping manually installing would end the problems Roundcube, but unfortunately I cannot login from a browser, it says "connection with IMAP server failed". I can login from Thunderbird, so mail is setup right. The file 'errors' in de Roundcube dir have the following lines: (2 different ports because I tried changing it)

      [15-Aug-2016 20:36:04 +0200]: IMAP Error: Login failed for from Could not connect to ssl://localhost:994: Unknown reason in /var/www/roundcube/program/lib/Roundcube/rcube_imap.php on line 193 (POST /roundcube/?_task=login&_action=login)
      [15-Aug-2016 20:37:08 +0200]: IMAP Error: Login failed for from Could not connect to ssl://localhost:144: Unknown reason in /var/www/roundcube/program/lib/Roundcube/rcube_imap.php on line 193 (POST /roundcube/?_task=login&_action=login)

      Any ideas?

      1. Ron,
        Can you please try adding the following lines to your file located in the folder /etc/webmail/config/:

        $config['imap_conn_options'] = array(
        'ssl' => array(
        'verify_peer' => true,
        'verfify_peer_name' => false,

  6. Hello
    Unless I am mistaken do you not need to install Postfix and Dovecoat? I don't see that anywhere listed and for someone new like me it is confusing :)

  7. Hi came across this tutorial on installing Roundcube. Pretty much everything worked till i tried to log in using the user created and it says " Connection to storage server failed" viewed the error logs and it says " Login failed for mailadmin from Could not connect to localhost:143: Connection refused in /var/www/html/webmail/program/lib/Roundcube/rcube_imap.php on line 193 (POST /webmail/?_task=login&_action=login)" checked my firewall and port 143 is able to communicate on it. Checked the router as well adn 143 is opened there as well. Used the lines in at the end of the file saved and restarted the server and also disabled the firewall for good measure. but i still cant log in. Please help.