In this tutorial, we will show you how to install and perform the first-time setup of Roundcube on Ubuntu 18.04<\/a>.<\/p>\r\n\r\n\r\n\r\n
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<\/a>.<\/p>\r\n\r\n\r\n\r\n
Table of Contents<\/p>\n
<\/p>\r\n\r\n\r\n\r\n
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<\/a>.<\/p>\r\n\r\n\r\n\r\n
To connect to your server as the root user, use the following command:<\/p>\r\n\r\n\r\n\r\n
ssh root@IP_ADDRESS<\/span> -p PORT_NUMBER<\/span><\/pre>\r\n\r\n\r\n\r\nMake sure to replace IP_ADDRESS<\/span> and PORT_NUMBER<\/span> with your actual server IP address and SSH port number.<\/p>\r\n\r\n\r\n\r\n
Once logged in, make sure that your server is up-to-date by running the following commands:<\/p>\r\n\r\n\r\n\r\n
sudo apt update\r\nsudo apt upgrade<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 2: Install Apache<\/span><\/h2>\r\n\r\n\r\n\r\n
To install Apache on your server, run the following command:<\/p>\r\n\r\n\r\n\r\n
sudo apt install apache2<\/pre>\r\n\r\n\r\n\r\nOnce the installation is complete, enable the Apache service to start automatically upon system boot. You can do that with the following command:<\/p>\r\n\r\n\r\n\r\n
sudo systemctl enable apache2<\/pre>\r\n\r\n\r\n\r\nTo verify that Apache is running, execute the following command:<\/p>\r\n\r\n\r\n\r\n
sudo systemctl status apache2<\/pre>\r\n\r\n\r\n\r\nOutput:<\/p>\r\n\r\n\r\n\r\n
\u25cf apache2.service - The Apache HTTP Server\r\n Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\r\n Drop-In: \/lib\/systemd\/system\/apache2.service.d\r\n \u2514\u2500apache2-systemd.conf\r\n Active: active (running) since Fri 2019-04-12 04:10:18 CDT; 3s ago\r\n Main PID: 1752 (apache2)\r\n Tasks: 6 (limit: 2321)\r\n CGroup: \/system.slice\/apache2.service\r\n \u251c\u25001752 \/usr\/sbin\/apache2 -k start\r\n \u251c\u25001753 \/usr\/sbin\/apache2 -k start\r\n \u251c\u25001754 \/usr\/sbin\/apache2 -k start\r\n \u251c\u25001755 \/usr\/sbin\/apache2 -k start\r\n \u251c\u25001756 \/usr\/sbin\/apache2 -k start\r\n \u2514\u25001757 \/usr\/sbin\/apache2 -k start<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 3: Install MySQL<\/span><\/h2>\r\n\r\n\r\n\r\n
The next step is to install the MySQL database server.<\/p>\r\n\r\n\r\n\r\n
To install MySQL on your system, type the following command and enter the character ‘Y’ when prompted:<\/p>\r\n\r\n\r\n\r\n
sudo apt install mysql-server<\/pre>\r\n\r\n\r\n\r\nDuring the installation, you will be asked to enter a password for the MySQL root user. Make sure to enter a strong password.<\/p>\r\n\r\n\r\n\r\n
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<\/code> script and follow the on-screen instructions. Run the command below to configure your system:<\/p>\r\n\r\n\r\n\r\n
sudo mysql_secure_installation<\/pre>\r\n\r\n\r\n\r\n
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.<\/p>\r\n\r\n\r\n\r\n
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’:<\/p>\r\n\r\n\r\n\r\n
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y<\/span>\r\n\r\nDisallow root login remotely? (Press y|Y for Yes, any other key for No) : Y<\/span>\r\n\r\nRemove test database and access to it? (Press y|Y for Yes, any other key for No) : Y<\/span>\r\n\r\nReload privilege tables now? (Press y|Y for Yes, any other key for No) : Y<\/span><\/pre>\r\n\r\n\r\n\r\n
Again, we can enable MySQL to start on boot with the following command:<\/p>\r\n\r\n\r\n\r\n
sudo systemctl enable mysql<\/pre>\r\n\r\n\r\n\r\nThat’s it – MySQL has been installed and made more secure.<\/p>\r\n\r\n\r\n\r\n
<\/span>Step 4: Install PHP<\/span><\/h2>\r\n\r\n\r\n\r\n
The last step of our LAMP stack setup is to install PHP. Ubuntu 18.04 comes with PHP 7.2 by default.<\/p>\r\n\r\n\r\n\r\n
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.<\/p>\r\n\r\n\r\n\r\n
To do this, type the following command:<\/p>\r\n\r\n\r\n\r\n
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<\/pre>\r\n\r\n\r\n\r\nThe following PHP PEAR packages are also required:<\/p>\r\n\r\n\r\n\r\n
sudo pear install Auth_SASL2 Net_SMTP Net_IDNA2-0.1.1 Mail_mime Mail_mimeDecode<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 5: Download Roundcube<\/span><\/h2>\r\n\r\n\r\n\r\n
We can now start with our Roundcube installation and configuration.<\/p>\r\n\r\n\r\n\r\n
Let’s download the latest stable Roundcube version (Complete package). You can do this with the following command:<\/p>\r\n\r\n\r\n\r\n
wget https:\/\/github.com\/roundcube\/roundcubemail\/releases\/download\/1.3.9\/roundcubemail-1.3.9-complete.tar.gz<\/pre>\r\n\r\n\r\n\r\nTo extract the file, execute the following command:<\/p>\r\n\r\n\r\n\r\n
sudo tar -xvzf roundcubemail-1.3.9-complete.tar.gz<\/pre>\r\n\r\n\r\n\r\nMove and rename the file to the following location on your server with:<\/p>\r\n\r\n\r\n\r\n
sudo mv roundcubemail-1.3.9 \/var\/www\/roundcube<\/pre>\r\n\r\n\r\n\r\nThe 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 \u201cwww-data<\/strong>\u201d user on Ubuntu.\u00a0 To change the owner and set the correct permissions of the files, you can run the following command:<\/p>\r\n\r\n\r\n\r\n
sudo chown -R www-data:www-data \/var\/www\/roundcube\/<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 6: Configure the Database<\/span><\/h2>\r\n\r\n\r\n\r\n
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:<\/p>\r\n\r\n\r\n\r\n
sudo mysql -u root -p<\/pre>\r\n\r\n\r\n\r\nTo create a new database and user, run the following commands on the MySQL shell:<\/p>\r\n\r\n\r\n\r\n
CREATE DATABASE roundcube;\r\nCREATE USER roundcube@localhost IDENTIFIED BY 'strong-password<\/span>';\r\nGRANT ALL PRIVILEGES ON roundcube.* TO roundcube@localhost;\r\nFLUSH PRIVILEGES;<\/pre>\r\n\r\n\r\n\r\n
Make sure to replace\u00a0strong-password<\/span> with an actual strong password.<\/p>\r\n\r\n\r\n\r\n
To exit the MySQL database server command line, type:<\/p>\r\n\r\n\r\n\r\n
exit<\/pre>\r\n\r\n\r\n\r\nNext, we need to import the Roundcube table layout into our empty database. To do this, run the following command:<\/p>\r\n\r\n\r\n\r\n
mysql -u roundcube -p roundcube < \/var\/www\/roundcube\/SQL\/mysql.initial.sql<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 7: Configure Apache<\/span><\/h2>\r\n\r\n\r\n\r\n
In this step, we will show you how to create a virtual host file for Apache<\/a> – this is so that you can access your Roundcube instance using your domain name.<\/p>\r\n\r\n\r\n\r\n
Create the virtual host file by executing the following command:<\/p>\r\n\r\n\r\n\r\n
nano \/etc\/apache2\/sites-available\/roundcube.conf<\/pre>\r\n\r\n\r\n\r\nAnd\u00a0enter the following information:<\/p>\r\n\r\n\r\n\r\n
<VirtualHost *:80>\r\n DocumentRoot \/var\/www\/roundcube\r\n ServerName webmail.mydomain.com \r\n<Directory \/var\/www\/roundcube\/>\t \t \r\n Options -Indexes\t \t \r\n AllowOverride All\t \t \r\n Order allow,deny\t \t \r\n allow from all\t \t \r\n <\/Directory>\t \t \r\n ErrorLog ${APACHE_LOG_DIR}\/roundcube_error.log\t \t \r\n CustomLog ${APACHE_LOG_DIR}\/roundcube_access.log combined\t \t \r\n<\/VirtualHost><\/pre>\r\n\r\n\r\n\r\nIn our example, we will use a subdomain called
webmail.mydomain.com<\/code>. Make sure to replace
webmail.mydomain.com<\/code>\u00a0with your actual domain\/subdomain name that you would like to use for your Roundcube.<\/p>\r\n\r\n\r\n\r\n
To enable the new Roundcube virtual host, run the following command:<\/p>\r\n\r\n\r\n\r\n
sudo a2ensite roundcube.conf<\/pre>\r\n\r\n\r\n\r\n
You should see the following output:<\/p>\r\n\r\n\r\n\r\n
Enabling site roundcube.<\/pre>\r\n\r\n\r\n\r\nTo activate the new configuration, you need to run:<\/p>\r\n\r\n\r\n\r\n
systemctl reload apache2<\/pre>\r\n\r\n\r\n\r\nYou also need to enable the Apache
mod_rewrite<\/code> module. You can do this with the following command:<\/p>\r\n\r\n\r\n\r\n
sudo a2enmod rewrite<\/pre>\r\n\r\n\r\n\r\n
Reload your Apache in order to activate the new configuration:<\/p>\r\n\r\n\r\n\r\n
sudo systemctl reload apache2<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 8: Installing Roundcube<\/span><\/h2>\r\n\r\n\r\n\r\n
You can now navigate to
http:\/\/webmail.mydomain.com\/installer\/<\/code> in your browser to start the Roundcube installation wizard.<\/p>\r\n\r\n\r\n\r\n
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<\/strong>” at the bottom of the page to continue to the next step.<\/p>\r\n\r\n\r\n\r\n
\r\n
<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n
On the next page, you will generate the Roundcube configuration file.<\/p>\r\n\r\n\r\n\r\n
In the General configuration<\/strong> section, you can choose the name of your email service, set a support page URL (optional) and choose a logo.<\/p>\r\n\r\n\r\n\r\n
\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n
In the Logging & Debugging<\/strong> section, you can leave everything to its default values.<\/p>\r\n\r\n\r\n\r\n
In the Database setup<\/strong> section, you need to enter your Roundcube database name, username, and password (the one we created in one of the previous steps).<\/p>\r\n\r\n\r\n\r\n
\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n
In the next two sections IMAP and SMTP Settings<\/strong>, 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.<\/p>\r\n\r\n\r\n\r\n
\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n
\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n
The Display settings & user prefs<\/strong> section provides some additional customization options.<\/p>\r\n\r\n\r\n\r\n
The last section is the Plugins<\/strong> section from where you can choose some of the many available plugins to be installed with your Roundcube.<\/p>\r\n\r\n\r\n\r\n
After you enter all the details and you are happy with your choices, click the “CREATE CONFIG<\/strong>” button.<\/p>\r\n\r\n\r\n\r\n
On the next page, you can test your Roundcube configuration, including your SMTP and IMAP settings.<\/p>\r\n\r\n\r\n\r\n
\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n
After completing the installation and the final tests you need to remove the whole installer directory from the document root of the webserver:<\/p>\r\n\r\n\r\n\r\n
sudo rm -rf \/var\/www\/roundcube\/installer<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 9: Accessing Roundcube<\/span><\/h2>\r\n\r\n\r\n\r\n
Once the installation is completed, you can navigate to
http:\/\/webmail.mydomain.com<\/code> (replace this with your actual domain name).<\/p>\r\n\r\n\r\n\r\n
This will take you to the Roundcube login screen, where you can use your email account credentials to log in and manage your emails.<\/p>\r\n\r\n\r\n\r\n
\r\n
<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n
That\u2019s it!\u00a0<\/strong>Roundcube Webmail has been successfully installed on your Ubuntu 18.04 server.<\/p>\r\n\r\n\r\n
\r\n\r\n\r\n\r\n<\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n
Of course, you don\u2019t have to\u00a0install Roundcube Webmail\u00a0<\/b>on Ubuntu 18.04<\/strong>\u00a0if you use our Managed Roundcube Hosting<\/a>\u00a0service. 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<\/a>. They are available 24\/7 and will be able to help you with the installation.<\/p>\r\n
You might also want to read our guide on How to Install Roundcube Webmail on Ubuntu 20.04<\/a>.<\/p>\r\n\r\n\r\n\r\n