How to Install RoundCube 1.4 on Ubuntu
Posted on June 15th, 2020
The RoundCube is an open-source, free webmail-client written in PHP language. Webmail is a mail client that we can use from the browser to receive and send emails instead of using the desktop mail clients, such as Thunderbird. Some of the standard functionalities of RoundCube includes folder management, message searching, address book, MIME support, and spell checking.
The features of RoundCube 1.4 releases are:
- It provides full mobile device support.
- It supports Memcached and Redis cache.
- Improvement in Mailvelope integration.
- It supports GSSAPI and SMTPUTF8.
In this tutorial, we can check how to Install RoundCube 1.4 on Ubuntu with Apache/Nginx.
Prerequisites
- The LAMP or LEMP stack should be pre-installed on the Ubuntu server.
- Also, Pre-install the Postfix SMTP and Dovecot IMAP server on the Ubuntu server.
So, Let’s get started with RoundCube Installation.
Install RoundCube Webmail
If the iRedMail is pre-installed on your Ubuntu server, then the RoundCube webmail should be already available on your server. But if you want to install RoundCube webmail on your server, First, Log in to the server as an ssh user with sudo privileges and then follow the below steps:
1) Download RoundCube
To download the latest 1.4 stable release of RoundCube from the GitHub repository, run the following command.
$ sudo wget https://github.com/roundcube/roundcubemail/releases/download/1.4.2/roundcubemail-1.4.2-complete.tar.gz
Then, extract the downloaded tar.gz file by executing the following command.
$ sudo tar -xvf roundcubemail-1.4.2-complete.tar.gz
Move the extracted file to the ‘roundcube’ folder under the webroot directory.
$ sudo mv roundcubemail-1.4.2 /var/www/roundcube
Now, We have successfully downloaded and moved the RoundCube files at a perfect location. Now, We have to install PHP extensions that the RoundCube mail depends on.
2) Install Dependencies
Before installing RoundCube, you need to install all the dependencies. Install the following dependencies.
Install the required PHP extensions by executing the following command.
$ sudo apt install php-net-ldap3 php-imagick php-net-ldap2 php7.2-common php7.2-imap php7.2-json php7.2-gd php7.2-curl php7.2-zip php7.2-xml php7.2-bz2 php7.2-intl php7.2-gmp php7.2-mbstring
Next, execute the following command to install Composer. The Composer is an application-level package manager for PHP language.
$ sudo apt install composer
Switch to the ‘/var/www/roundcube’ directory.
$ sudo cd /var/www/roundcube
Then, install all the necessary dependencies for RoundCube Webmail using the composer.
$ sudo composer install --no-dev
If you see the ‘nothing to install or upgrade’ message, then all the dependencies are available on the server.
Change the owner of the ‘temp’ and ‘logs’ directory to ‘www-data’. This command gives privilege to the webserver to write to these directories.
$ sudo chown -R www-data:www-data temp/ logs/
We have to give ownership to www-data
because it will require access to these two folders while the application is being used.
3) Create a MariaDB Database and User
Now we have to create a MariaDB/MySQL database and a user to allow RoundCube to manage the data in the database. Log in to MariaDB as a root user.
$ sudo mysql -u root
Execute the following command to create a new database for RoundCube. In the following command, replace the <database_name> flag with the name for your database.
> CREATE DATABASE <database_name> DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Execute the following command to create a new database user for RoundCube. In the following command, replace the <database_user> and <user_password> flags with the database username and password, respectively.
> CREATE USER <database_user>@localhost IDENTIFIED BY ‘<user_password>’;
Then, grand full permission of the database to the newly created user to make sure that Roundcube can write to the database later.
> GRANT ALL PRIVILEGES ON <database_name>.* TO <database_user>@localhost;
Execute the following flush command to make the changes to take effect.
> FLUSH PRIVILEGES;
Then, exit the MariaDB shell.
> EXIT;
Then, import the initial tables to the newly created database. For example, if the database name is ‘roundcube’, then execute the following command to import the initial tables.
$ sudo mysql roundcube < /var/www/roundcube/SQL/mysql.initial.sql
Once it’s done, we have to create an Apache or Nginx Virtual Host. You can create the virtual host based on the webserver you are using.
4) Create Nginx Config File or Apache Virtual Host
4.1) Create Nginx Config File for Roundcube
First, create and open the Nginx config file for Roundcube.
$ sudo nano /etc/nginx/conf.d/roundcube.conf
Paste the following lines in the ‘roundcube.conf’ file. In the following lines, replace the <domain_name> flag with your actual domain name and set the DNS A record for the same. After that, save and close the file.
server {
listen 80;
server_name mail.<domain_name>;
root /var/www/roundcube/;
index index.php index.html index.htm;
error_log /var/log/nginx/roundcube.error;
access_log /var/log/nginx/roundcube.access;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.well-known/acme-challenge {
allow all;
}
location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
deny all;
}
location ~ ^/(bin|SQL)/ {
deny all;
}
# A long browser cache lifetime can speed up repeat visits to your page
location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
}
Then, test the Nginx configuration by executing the following command.
$ sudo nginx -t
After that, reload Nginx to reflect the changes.
$ sudo systemctl reload nginx
Now, you can access the Roundcube web-based installation wizard from any of the browsers by using the following URL.
http://mail.<domain_name>/installer
4.2) Create Apache Virtual Host for Roundcube
First, create and open the Apache virtual host.
$ sudo nano /etc/apache2/sites-available/roundcube.conf
Paste the following text in the file. In the following lines, replace the <domain_name> with the actual domain name and set the DNS A record for the same. After that, save and close the file.
<VirtualHost *:80> ServerName mail.<domain_name> DocumentRoot /var/www/roundcube/ ErrorLog ${APACHE_LOG_DIR}/roundcube_error.log CustomLog ${APACHE_LOG_DIR}/roundcube_access.log combined <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/roundcube/> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost>
Execute the following command to enable the created virtual host.
$ sudo a2ensite roundcube.conf
After that, reload Apache to reflect the changes.
$ sudo systemctl reload apache2
Now, you can access the Roundcube web-based installation wizard from any of the browsers by using the following URL.
http://mail.<domain_name>/installer
5) Finish the RoundCube Webmail Installation
Hit the following URL in any of the browsers.
http://mail.<domain_name>/installer
Web browser checks if all the dependencies are available on the server and display the result. If everything is ‘Ok’, then press the ‘Next’ button.
On the next page, fill the details of the newly created database.
Then, configure how to send and receive an email in the IMAP and SMTP section.
SMTP
IMAP
If you want to enable any plugins, then you can do that from the plugins section. After that, click the ‘Create config’ button. This process generates a configuration based on the details you entered. Copy and paste that configuration into the ‘/var/www/roundcube/config/config.inc.php’ file.
After saving the file, click the ‘Continue’ button.
Next, test the IMAP and SMTP settings by checking the IMAP login and sending a test email.
If the test is successful, then you can log in to the RoundCube webmail by using the following URL. But if it fails, then go back to the ‘Create config’ link and recreate the configuration file.
http://mail.<domain_name>
Then, remove the installer folder from the document root by executing the following command. Before that, make sure that you disable the ‘enable_installer’ option in ‘/var/www/roundcube/config/config.inc.php’ file.
$ sudo rm -r /var/www/roundcube/installer/
These files can expose sensitive data to the public, such as username, server password, and encryption key. After removing the above files, make sure that you can’t access the installation page from the browser.
Conclusion
The RoundCube is an open-source, free webmail client. Webmail is a mail client that we can use to receive and send emails from a web browser. We hope that this knowledge base was helpful to you. Please comment below for any questions or queries. If you are an InterServer customer, please reach out to our support team for further help.