How to install RoundCube Webmail on Ubuntu 18.04/20.04 and Debian 9/10

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

In this post, you will learn how to install RoundCube Webmail on Ubuntu / Debian

Roundcube is free open-source web-based email client written in PHP. We can access webmail client in our browser, meaning that instead of using Desktop based Web Clients we can access our mailbox in Browser. It has suppoprt for LAMP/LEMP Stack, We can import mails from mailboxes like Google,Yahoo etc. It has features like Message Filter, MIME Support, Spell Checking, Folder management etc.

Requirements :

  • Fresh Ubuntu 18.04/20.04 or greater or Debian 9/10 VPS Server
  • Minimum of 1GB of RAM
  • FQDN (Not necessary but if using a domain)
  • VPS with Root Access

Step 1 : Updating your VPS

Before starting our tutorial, First we will update our VPS

apt-get update -y
apt-get upgrade -y

Step 2 : Installing PHP

PHP7 is supported for RoundCube, To install PHP7 Packages on Debian or Ubuntu servers first we would have to run some commands. By default we cannot install PHP7.x packges on Debian, for that we have to enable PPA by using the following commands.

— Do the following for Debian Servers to install PHP 7.X Packages

apt install apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo “deb https://packages.sury.org/php/ $(lsb_release -sc) main” > /etc/apt/sources.list.d/php.list
apt update

— Do the following for Ubuntu Servers to install PHP 7.X Packages

apt -y install software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update

Next, Run the following commands to install the required PHP Modules

apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-curl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-intl php7.2-ldap php7.2-imagick php7.2-json php7.2-cli

Step 3 : Installing Apache2 Server

Roundcube supports majority of the web servers like nginx etc. In our case we will be using apache2 as our web server

apt-get install apache2

Step 4 : Installing MariaDB Server

We will need a database to store our RoundCube Data which includes user login infos etc. For this we will be using MariaDB Server. Run the following commands to install the server

apt-get install mariadb-server mariadb-client

Step 4(b): Configuring MariaDB

After installing MariaDB, We have to configure it by running the following command

mysql_secure_installation

After running this you will be prompted some options, Do as the following image attached below or do it as the text

Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

To test whether MySQL or MariaDB Server is running run the following command

mysql -u root -p

After that you will see a output like this which will confirm that infact the server is running

Step 5 : Configure Database for RoundCube

We have now installed most of the packages that are required for the RoundCube Web mail Client. We have successfully setup our MariaDB Database Server. Now we can continue to configure a database by the following commands

mysql -u root -p

– Run the following commands in the MariaDB CLI

CREATE DATABASE roundcube;
CREATE USER ’roundcubeuser’@localhost IDENTIFIED BY ‘password’;
GRANT ALL PRIVILEGES ON roundcube.* TO ’roundcubeuser’@localhost;
exit;

Step 6 : Download & install RoundCube webmail

If you have followed the tutorial till now, You have successfully setup a LAMP Stack which is required for RoundCube, Now we can move on to downloading files and configuring the Web Mail Client

cd /tmp
wget https://github.com/roundcube/roundcubemail/releases/download/1.5.2/roundcubemail-1.5.2-complete.tar.gz

Extract the content using tar and move it to the Apache2 Web Folder

tar -xvzf roundcubemail-1.5.2-complete.tar.gz
mv roundcubemail-1.5.2 /var/www/html/roundcube

— Next step is too import the Content of the Roundcube Database to our newly database created

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

It would give a following output, You will prompted to enter your password

Change Permissions for the files of RoundCube:

chown -R www-data:www-data /var/www/html/roundcube/
find /var/www/html/roundcube/ -type d -exec chmod 750 {} \;
find /var/www/html/roundcube/ -type f -exec chmod 640 {} \;

Step 7 : Configuring Apache2 VirtualHost

RoundCube Mail will work on bare IP Address but if you want to connect your FQDN to your server you must configure a VirtualHost for Apache2 and RoundCube. Run the following commands to connect your Domain to RoundCube

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

Paste the following content into the file :

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/roundcube
     ServerName mail.domainname.com

     <Directory /var/www/html/roundcube/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

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

</VirtualHost>

— Replace the ServerName with your own FQDN and the ServerAdmin with your own Email Address and save the file.

It should look like the following:

Enable the RoundCube VirtualHost by running the following command :

a2ensite roundcube.conf
systemctl reload apache2.service

Step 8 : Run the Web Installer

You have sucessfully configured everything required for the web client, Run the installer at link

http://yourdomainname.com/installer

1. First page you will see with all the checks, If you have done everything from above just click on next

Install RoundCube Webmail on Ubuntu / Debian
Install RoundCube Webmail on Ubuntu / Debian

2. On the second page, Edit the Database Settings as following

Then press next and press continue:

Install RoundCube Webmail on Ubuntu / Debian
Install RoundCube Webmail on Ubuntu / Debian

You have successfully installed RoundCube on your VPS. You can now delete the installer folder by using the following command

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

Conclusion:

RoundCube WebMail Client has been installed on your VPS. This tutorial is a straightforward method of setting up a LAMP Stack for RoundCube. Next tutorial will be for configuring IMAP, SMTP etc for RoundCube.

So, you know How to install RoundCube Webmail on Ubuntu / Debian

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
sAmI
sAmIhttps://losersgaming.com
I'm a freelancer and a semi-professional VALORANT Player from Pakistan, Expert in Network & System Administration & WordPress Developing.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook