How to Install RoundCube Webmail on Debian 9

How to Install RoundCube Webmail on Debian 9

In this tutorial, we will show you how to install RoundCube on a Debian 9 VPS. RoundCube is an open-source web-based IMAP email client written in PHP with an application-like user interface. It allows users to read, send, and organize their emails easily. One of the most prominent features of RoundCube webmail is the widespread use of Ajax technology and find-as-you-type address book integration. Install RoundCube Webmail on a Debian 9 VPSThe RoundCube webmal user interface is very customizable and it is available in over 80 languages.

Prerequisites

  • For the purposes of this tutorial, we will use a Debian 9 virtual server.
  • A working mail server with Postfix, SendMail or Exim, and Dovecot installed and configured on the VPS.
  • Apache, Nginx, LiteSpeed, Lighttpd, Hiawatha or Cherokee web server with PHP support.
  • PHP 5.4 or higher (PHP 7 or higher is preferred) with the following PHP extensions enabled: DOM, JSON, XML, Mbstring, OpenSSL, PHP Data Objects (PDO) with driver for either MySQL, PostgreSQL, SQL Server or SQLite. Optionally, we can install Iconv, FileInfo, Zip and Pspell PHP extensions.
  • Full SSH root access or a user with sudo privileges is also required.

Step 1: Connect via SSH

Connect to your server via SSH as the root user using the following command:

ssh root@IP_ADDRESS -p PORT_NUMBER

Remember to replace “IP_ADDRESS” and “PORT_NUMBER” with your actual server IP address and SSH port number. Replace “root” with your admin username if you’re not planning on using the root account.

Before starting with the installation, we need to update the OS packages to their latest versions.

We can do this by running the following commands:

apt-get update 
apt-get upgrade

Once the upgrade is complete, we can move on to the next step.

Step 2: Install Apache

We can install Apache2 from the Debian package repository.

Run the following commands to install Apache2 on the server:

sudo apt-get update
sudo apt-get install apache2

Enable Apache2 to start on server boot:

systemctl enable apache2.service

Step 3: Install PHP and PHP Extensions Required by RoundCube

For RoundCube, we’ll be installing PHP version 7.0. With this command, we will install PHP 7.0 as well as download and install all of the required PHP extensions and pear packages:

sudo apt-get install php7.0 php7.0-common php7.0-curl php7.0-xml php7.0-json php7.0-dev php7.0-mysql php7.0-mbstring php7.0-intl php7.0-ldap php7.0-imagick php-pear
sudo phpenmod intl mcrypt mbstring
cd /opt; wget http://pear.php.net/go-pear.phar
php go-pear.phar  (press Enter)
pear channel-update pear.php.net
sudo pear channel-update pear.php.net
sudo pear install Auth_SASL Net_SMTP Net_IDNA2-0.1.1 Mail_Mime Mail_mimeDecode
sudo pear install --alldeps channel://pear.php.net/Auth_SASL2-0.2.0 Auth_SASL2

Step 4: Create the Apache Configuration File

Create a new Apache configuration file for the domain/subdomain name that we will be using to access the RoundCube webmail application. For this tutorial, we will be using ‘webmail.domain.com‘.

nano /etc/apache2/sites-available/roundcube.conf
<VirtualHost *:80>
ServerName webmail.domain.com
DocumentRoot /var/www/roundcube

CustomLog ${APACHE_LOG_DIR}/webmail.domain.com.access.log combined
ErrorLog ${APACHE_LOG_DIR}/webmail.domain.com.error.log

<Directory /var/www/roundcube>
DirectoryIndex index.php
Options -Indexes
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>

Do not forget to replace webmail.domain.com with your actual domain/subdomain name. Save and close the file.

Create a new directory named roundcube:

mkdir -p /var/www/roundcube

To enable the newly created configuration file in Apache, run:

sudo a2ensite roundcube

Disable the default Apache configuration file using:

sudo a2dissite 000-default

Also, we need to enable Apache rewrite module if it is not already enabled:

sudo a2enmod rewrite

Check if there are errors with the newly created Apache configuration:

sudo apachectl -t
Syntax OK

If the syntax is OK and there are no errors, we can restart Apache web service.

sudo systemctl restart apache2.service

Step 5: Create a MySQL Database

Create a new MySQL database:

mysql -u root -p
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS `roundcube` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON roundcube.* TO roundcubeuser@localhost IDENTIFIED BY 'Str0nGPa55W0rd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> quit

(do not forget to replace ’roundcubeuser’ and ‘Str0nGPa55W0rd’ fields accordingly)

Step 6: Install RoundCube on Debian 9

There are two ways to install RoundCube webmail: using a .deb package from the official Debian package repository, or using source files from Github. For the purposes of this tutorial, we will download and install RoundCube from source. In order to get the latest stable version of RoundCube, we will download it from https://github.com/roundcube/roundcubemail .

To download the latest RoundCube version, run the following commands:

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

Run the command below to extract the RoundCube Webmail application files in the /var/www/ directory on your server:

tar -xzf roundcubemail-* -C /var/www --transform s/roundcubemail-1.3.9/roundcube/

We need to change the permissions of RoundCube files located in the/var/www/roundcube directory:

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

Apply the initial configuration to the RoundCube database using the following command:

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
mysql -u roundcubeuser -p roundcube < /var/www/roundcube/SQL/mysql.initial.sql

Create a new cron job and enable Roundcube’s cache-cleaning script:

0 3 * * * root /bin/bash /var/www/roundcube/bin/cleandb.sh > /dev/null 2>&1

Open your favorite web browser and navigate to http://webmail.domain.com/installer/

roundcube installer
If all the requirements are met, you should click on the ‘NEXT’ button. On the next page, enter roundcube as database name, roundcubeuser as database user name and enter your database password. Click the ‘CREATE CONFIG’ button, then click ‘CONTINUE’. Remove the entire installer directory from the document root of the web server:

rm -rf /var/www/roundcube/installer

Or, make sure that ‘enable_installer’ option in config.inc.php is disabled.

That is it – the RoundCube installation is now complete.

Open your favorite web browser, navigate to http://webmail.domain.com and log in using your email account login credentials. There are many RoundCube plugins available to be installed, such as calendar, desktop notifications, vacation, custom-from, reCAPTCHA, login_control, smart_autocomplete, and so on.


Installing RoundCube Webmail on Debian 9Of course, you don’t have to install RoundCube on Debian 9 if you use one of our Managed RoundCube Hosting solutions, in which case you can simply ask our expert Linux admins to set up RoundCube for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to install RoundCube on a Debian 9 VPS, please share it with your friends on the social networks using the share shortcuts below, or simply leave a comment in the comments section. Thanks.

3 thoughts on “How to Install RoundCube Webmail on Debian 9”

    • We have some posts about it, you can check them at https://www.rosehosting.com/blog/?s=postfixadmin&submit=

      Reply
  1. Also you’ll have to execute the following to install JS dependencies :

    sudo /var/www/roundcube/bin/install-jsdeps.sh

    Reply

Leave a Comment