How to Install Roundcube Webmail on Ubuntu 18.04

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.

Install Roundcube Webmail on an Ubuntu 18.04 VPS

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. Check out our guide if you’re interested in learning more about the differences between IMAP and POP.

Prerequisites

  • 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 root@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

Output:

● 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
           └─apache2-systemd.conf
   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:

wget https://github.com/roundcube/roundcubemail/releases/download/1.3.9/roundcubemail-1.3.9-complete.tar.gz

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 DATABASE roundcube;
CREATE USER roundcube@localhost IDENTIFIED BY 'strong-password';
GRANT ALL PRIVILEGES ON roundcube.* TO roundcube@localhost;
FLUSH PRIVILEGES;

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

To exit the MySQL database server command line, type:

exit

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
     ServerName webmail.mydomain.com 
<Directory /var/www/roundcube/>	 	 
 Options -Indexes	 	 
 AllowOverride All	 	 
 Order allow,deny	 	 
 allow from all	 	 
 </Directory>	 	 
 ErrorLog ${APACHE_LOG_DIR}/roundcube_error.log	 	 
 CustomLog ${APACHE_LOG_DIR}/roundcube_access.log combined	 	 
</VirtualHost>

In our example, we will use a subdomain called webmail.mydomain.com. Make sure to replace webmail.mydomain.com 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 http://webmail.mydomain.com/installer/ 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 its 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.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS

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 http://webmail.mydomain.com (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.


Installing Roundcube Webmail on Ubuntu 18.04

Of course, you don’t have to install Roundcube Webmail on Ubuntu 18.04 if you use our Managed Roundcube Hosting service. Additionally, you can simply ask our support team to install Roundcube on Ubuntu 18.04 for you if you use one of our Managed Linux VPSes. They are available 24/7 and will be able to help you with the installation.

You might also want to read our guide on How to Install Roundcube Webmail on Ubuntu 20.04.

PS. If you enjoyed reading this blog post on how to install Roundcube Webmail on Ubuntu 18.04, feel free to share it on social networks using the shortcuts below, or simply leave a comment in the comments section. Thanks.

5 thoughts on “How to Install Roundcube Webmail on Ubuntu 18.04”

  1. Thanks for the great write-up! One comment (so far):
    The last command in step 6 when you import the Roundcube table layout – you might need to change directories in your command line. In the prior steps you moved the extracted directory to /var/www/roundcube – you may need to change to this directory for executing the last command in step 6.

    Reply
  2. I installed Roundcube on Ubuntu, and the configuration is stored in /etc/roundcube and the program in /usr/share/roundcube. I renamed these folders to include the Roundcube version number and then replaced the original with a symlink to the current folder. This makes it easier when Roundcube gets upgraded. I clone the two current folders, backup the database, and then apply the upgrade against the cloned folders. That way, if I have to go back to a previous version, all I have to do is change the symlinks to point to the right folders and restore the database to that version. Voila!

    Reply
  3. Hi, I have install and everything is set up and I am stuck in the login page don’t know what is the username and password.

    Reply

Leave a Comment