How to Install Roundcube Webmail on Ubuntu 18.04


In this tutorial, we will show you how to install and perform the first-time setup of Roundcube on Ubuntu 18.04.

Read More

Roundcube Webmail is a free and open-source web-based IMAP client, written in PHP. With its intuitive and desktop-like user interface, Roundcube provides an easy way for you to check and manage your emails using your web browser.
It provides all of the functionalities that you would come to expect from an email client, including full MIME and HTML support, an address book, folder management, advanced message searching, spell checking, and much more.


  • For the purposes of this tutorial, we will be using an Ubuntu 18.04 VPS.
  • You will also need a working LAMP or LEMP (Linux, Apache/Nginx, MySQL, PHP) stack.
  • A working IMAP based email server so that you can send/receive emails. You can check our tutorial on how to set up a mail server with Postfix and Dovecot.
  • Full SSH root access or a user with sudo privileges is also required.

Step 1: Connect to Your Server

Before we begin, you will need to connect to your server via SSH as the root user or as any other user that has sudo privileges.

To connect to your server as the root user, use the following command:

ssh [email protected]IP_ADDRESS -p PORT_NUMBER

Make sure to replace IP_ADDRESS and PORT_NUMBER with your actual server IP address and SSH port number.

Once logged in, make sure that your server is up-to-date by running the following commands:

sudo apt update
sudo apt upgrade

Step 2: Install Apache

To install Apache on your server, run the following command:

sudo apt install apache2

Once the installation is complete, enable the Apache service to start automatically upon system boot. You can do that with the following command:

sudo systemctl enable apache2

To verify that Apache is running, execute the following command:

sudo systemctl status apache2


● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
   Active: active (running) since Fri 2019-04-12 04:10:18 CDT; 3s ago
 Main PID: 1752 (apache2)
    Tasks: 6 (limit: 2321)
   CGroup: /system.slice/apache2.service
           ├─1752 /usr/sbin/apache2 -k start
           ├─1753 /usr/sbin/apache2 -k start
           ├─1754 /usr/sbin/apache2 -k start
           ├─1755 /usr/sbin/apache2 -k start
           ├─1756 /usr/sbin/apache2 -k start
           └─1757 /usr/sbin/apache2 -k start

Step 3: Install MySQL

The next step is to install the MySQL database server.

To install MySQL on your system, type the following command and enter the character ‘Y’ when prompted:

sudo apt install mysql-server

During the installation, you will be asked to enter a password for the MySQL root user. Make sure to enter a strong password.

To further improve the security of our MySQL installation as well as set up a password for our MySQL root user, we need to run the mysql_secure_installation script and follow the on-screen instructions. Run the command below to configure your system:

sudo mysql_secure_installation

If the program asks you to enter your current MySQL root password, just press your [Enter] key once, as no password is set by default when installing MySQL.

A few more questions will be displayed on-screen – it is recommended that you answer yes to all of them by entering the character ‘Y’:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y

Again, we can enable MySQL to start on boot with the following command:

sudo systemctl enable mysql

That’s it – MySQL has been installed and made more secure.

Step 4: Install PHP

The last step of our LAMP stack setup is to install PHP. Ubuntu 18.04 comes with PHP 7.2 by default.

We will also include some additional modules in order to help PHP to connect with our Apache and MySQL servers. On top of these, we will install modules that are required by Roundcube.

To do this, type the following command:

sudo apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mysql php7.2-cli php-pear php7.2-opcache php7.2-gd php7.2-curl php7.2-cli php7.2-imap php7.2-mbstring php7.2-intl php7.2-soap php7.2-ldap php-imagick 7.2-xmlrpc php7.2-xml php7.2-zip

The following PHP PEAR packages are also required:

sudo pear install Auth_SASL2 Net_SMTP Net_IDNA2-0.1.1 Mail_mime Mail_mimeDecode

Step 5: Download Roundcube

We can now start with our Roundcube installation and configuration.

Let’s download the latest stable Roundcube version (Complete package). You can do this with the following command:


To extract the file, execute the following command:

sudo tar -xvzf roundcubemail-1.3.9-complete.tar.gz

Move and rename the file to the following location on your server with:

sudo mv roundcubemail-1.3.9 /var/www/roundcube

The owner of the files needs to be the user of the web server running on your system. In our example, we are using the Apache web server and Apache runs under the “www-data” user on Ubuntu. To change the owner and set the correct permissions of the files, you can run the following command:

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

Step 6: Configure the Database

Next, we need to create a new database. To do this, log in to your MySQL database server as the root user by typing the following command:

sudo mysql -u root -p

To create a new database and user, run the following commands on the MySQL shell:

CREATE USER [email protected] IDENTIFIED BY 'strong-password';
GRANT ALL PRIVILEGES ON roundcube.* TO [email protected];

Make sure to replace strong-password with an actual strong password.

To exit the MySQL database server command line, type:


Next, we need to import the Roundcube table layout into our empty database. To do this, run the following command:

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

Step 7: Configure Apache

In this step, we will show you how to create a virtual host file for Apache – this is so that you can access your Roundcube instance using your domain name.

Create the virtual host file by executing the following command:

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

And enter the following information:

<VirtualHost *:80>
     DocumentRoot /var/www/roundcube
<Directory /var/www/roundcube/>	 	 
 Options -Indexes	 	 
 AllowOverride All	 	 
 Order allow,deny	 	 
 allow from all	 	 
 ErrorLog ${APACHE_LOG_DIR}/roundcube_error.log	 	 
 CustomLog ${APACHE_LOG_DIR}/roundcube_access.log combined	 	 

In our example, we will use a subdomain called Make sure to replace with your actual domain/subdomain name that you would like to use for your Roundcube.

To enable the new Roundcube virtual host, run the following command:

sudo a2ensite roundcube.conf

You should see the following output:

Enabling site roundcube.

To activate the new configuration, you need to run:

systemctl reload apache2

You also need to enable the Apache mod_rewrite module. You can do this with the following command:

sudo a2enmod rewrite

Reload your Apache in order to activate the new configuration:

sudo systemctl reload apache2

Step 8: Installing Roundcube

You can now navigate to in your browser to start the Roundcube installation wizard.

The first page will check if all server requirements are met. If there are some missing dependencies, you should install them on your server and then refresh the page again. Once you make sure everything is set up properly, you can click on “NEXT” at the bottom of the page to continue to the next step.


On the next page, you will generate the Roundcube configuration file.

In the General configuration section, you can choose the name of your email service, set a support page URL (optional) and choose a logo.


In the Logging & Debugging section, you can leave everything to their default values.

In the Database setup section, you need to enter your Roundcube database name, username, and password (the one we created in one of the previous steps).


In the next two sections IMAP and SMTP Settings, you will need to enter the settings for your email server, so that you can send and receive emails. If you do not have your own mail server, you can also use other free email services – such as Gmail from Google – and connect Roundcube to their servers.


The Display settings & user prefs section provides some additional customization options.

The last section is the Plugins section from where you can choose some of the many available plugins to be installed with your Roundcube.

After you enter all the details and you are happy with your choices, click the “CREATE CONFIG” button.

On the next page, you can test your Roundcube configuration, including your SMTP and IMAP settings.


After completing the installation and the final tests you need to remove the whole installer directory from the document root of the webserver:

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

Step 9: Accessing Roundcube

Once the installation is completed, you can navigate to (replace this with your actual domain name).

This will take you to the Roundcube login screen, where you can use your email account credentials to log in and manage your emails.


That’s it! Roundcube Webmail has been successfully installed on your Ubuntu 18.04 server.

Original Article