Port_Number<\/code> are the actual IP address of your server and SSH port number.<\/p>\n\n\n\nNow, the first thing we should do is to make sure that all installed packages are updated to the latest available version:<\/p>\n\n\n\n
apt update && apt upgrade<\/pre>\n\n\n\nWe also suggest restarting your server so that all configuration files being used are the latest version.<\/p>\n\n\n\n
Step 2. Install MariaDB server<\/h2>\n\n\n\n
Roundcube needs a database where it will store its preferences, users, contacts and email messages (if caching is enabled). So for this purpose we will install MariaDB server. MariaDB is an open-source variant of MySQL. The MariaDB package is available in the official Ubuntu 20.04 repository, so the installation is pretty easy.<\/p>\n\n\n\n
apt install mariadb-server<\/pre>\n\n\n\nOnce the database server is installed, start it and enable it to automatically start after a server reboot.<\/p>\n\n\n\n
systemctl start mariadb\nsystemctl enable mariadb<\/pre>\n\n\n\nAdditionally, you can run the mysql_secure_installation<\/code> post installation script, to strengthen the security of the MariaDB server as well as set a password for the MariaDB root user. It’s optional, but we strongly recommend securing your database server properly.<\/p>\n\n\n\nStep 3. Create a MariaDB database and User<\/h2>\n\n\n\n
We have the database server up and running, so we can proceed and create a database and user for Roundcube. Login to the database server as the root user, enter your password if you set one on the previous step, then run the following SQL commands:<\/p>\n\n\n\n
mysql -u root -p\n\nMariaDB [(none)]> CREATE DATABASE IF NOT EXISTS `roundcube` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;\nMariaDB [(none)]> GRANT ALL PRIVILEGES ON roundcube.* TO roundcubeuser@localhost IDENTIFIED BY 'PASSWORD<\/strong>';\nMariaDB [(none)]> FLUSH PRIVILEGES;\nMariaDB [(none)]> quit<\/pre>\n\n\n\nDon’t forget to replace ‘PASSWORD<\/strong><\/code>‘ with an actual strong password.<\/p>\n\n\n\nStep 4. Install PHP and its Dependencies<\/h2>\n\n\n\n
Roundcube is a PHP-based application, therefore we need to install PHP along with some PHP extensions that are required by Roundcube.<\/p>\n\n\n\n
apt install php7.4 php7.4-gd php7.4-common php7.4-json php-imagick php7.4-imap php7.4-xml php7.4-opcache php7.4-mbstring php7.4-curl php7.4-zip php7.4-bz2 php7.4-intl<\/pre>\n\n\n\nOnce all packages are installed, you can check the installed PHP version with the following command:<\/p>\n\n\n\n
php -v<\/pre>\n\n\n\nPHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies<\/pre>\n\n\n\nStep 5. Install Apache and Create a Virtual Host<\/h2>\n\n\n\n
Roundcube is webmail solution, so we have to install web server to serve the Roundcube file. It supports almost all of the major web servers, but in this tutorial we will use Apache. It can be easily installed with the following command<\/p>\n\n\n\n
apt -y install apache2<\/pre>\n\n\n\nOnce the APT package manager completes the installation, start the web server and enable it to start upon a reboot<\/p>\n\n\n\n
systemctl start apache2\nsystemctl enable apache2<\/pre>\n\n\n\nNext, create Apache virtual host directory, so you can access Roundcube with a domain or subdomain, instead of your server’s IP address.<\/p>\n\n\n\n
vim \/etc\/apache2\/sites-available\/roundcube.domain.com.conf<\/pre>\n\n\n\n<VirtualHost *:80>\n ServerName roundcube.domain.com<\/strong>\n DocumentRoot \/var\/www\/roundcube\/\n\n ErrorLog ${APACHE_LOG_DIR}\/roundcube.domain.com<\/strong>_error.log\n CustomLog ${APACHE_LOG_DIR}\/roundcube.domain.com<\/strong>_access.log combined\n \n Options FollowSymLinks\n AllowOverride All\n \n Options FollowSymLinks MultiViews\n AllowOverride All\n Order allow,deny\n allow from all\n<\/VirtualHost><\/pre>\n\n\n\nSave the file and run the following command to enable the virtual host:<\/p>\n\n\n\n
a2ensite roundcube.domain.com<\/pre>\n\n\n\nFinally, reload the web server for the changes to take effect:<\/p>\n\n\n\n
systemctl reload apache2<\/pre>\n\n\n\nStep 6. Download and Install Roundcube<\/h2>\n\n\n\n
We have all of our prerequisites configured on the server, so we can go ahead and download the most recent release of Roundcube. At the moment of writing the article, it is version 1.4.6. Go to the Download page of Roundcube’s official website, copy the URL, and download the complete package:<\/p>\n\n\n\n
wget https:\/\/github.com\/roundcube\/roundcubemail\/releases\/download\/1.4.6\/roundcubemail-1.4.6-complete.tar.gz<\/pre>\n\n\n\nThe next command will unpack the downloaded tarball archive and rename the directory:<\/p>\n\n\n\n
tar -xzf roundcubemail-1.4.6-complete.tar.gz -C \/var\/www\/html --transform s\/roundcubemail-1.4.6\/roundcube\/<\/pre>\n\n\n\nChange the permissions of the Roundcube content directory to www-data<\/code>, the owner for the web server:<\/p>\n\n\n\nchown www-data: -R \/var\/www\/html\/roundcube<\/pre>\n\n\n\nInitiate the Roundcube database:<\/p>\n\n\n\n
mysql -u roundcubeuser -p roundcube < \/var\/www\/html\/roundcube\/SQL\/mysql.initial.sql<\/pre>\n\n\n\nNext, go to http:\/\/roundcube.domain.com<\/strong>\/installer<\/code> enter all the necessary details. The installation wizard will create the Roundcube configuration file and then webmail will be ready to use.<\/p>\n\n\n\nBefore going any futher, don’t forget to remove the installer<\/code> directory:<\/p>\n\n\n\nrm -rf \/var\/www\/html\/roundcube\/installer<\/pre>\n\n\n\nFinally, visit http:\/\/roundcube.domain.com<\/strong><\/code> and login to Roundcube with your email account.<\/p>\n\n\n\n