How to Install Webmail in CentOS 7

While the Linux system comes with mail-reading facility built in, the environment is really not convenient for those who don’t love the command line that much. A graphical client offers a lot more ease and features. For setting up an email client in CentOS 7, you have two options: Set up a GUI-based client such as Thunderbird, or access email via a web interface.

 

The webmail idea is also relevant for those who want to run their own mail servers locally, as it would do away with the need to install compatible email clients separately.

 

Installing RoundCube Webmail on CentOS 7

 

RoundCube is one of the more popular webmail software on CentOS 7, and in this tutorial, we’ll see just how to install that. There are several steps to it, so let’s take it slow and easy.

 

Step 1: Install web server

 

The very first thing we need, no surprise here, is a web server that can execute the webmail client from within a browser. The two heavyweights for consideration here are Apache and Nginx. Nginx has more or less won the race by now, thanks to its event-driven architecture that allows it to handle much higher loads and use fewer resources than Apache.

 

Make sure you are logged in as root, and then execute the following commands:

 

# yum install epel-release

# yum install nginx

 

Once this is done, you need to start Nginx, as well as tell the system to start it every time there’s a reboot:

 

# systemctl start nginx

# systemctl enable nginx

 

With this, Nginx is now installed.

 

Step 2: Install database package

 

Next, we need to install a database where RoundCube can store the data it accesses or generates. MySQL and MariaDB are the (only?) two choices here, and the difference comes down to how “open” you want to be. MySQL is controlled by Oracle now, and many people aren’t too happy with that. Further, do note that openness isn’t the only consideration now.

 

Since version 5.5, MariaDB has started diverging from MySQL, and by now has developed significant incompatibilities. You can still migrate from MySQL to MariaDB painlessly, but the reverse is a path fraught with many dangers. Point is, choosing a database will have long-term consequences.

 

Assuming you want to go ahead with MariaDB, you need to install the package first:

 

# yum install mariadb-server

 

Once the installation is completed, you need to enable MariaDB the same way you did with Nginx:

 

# systemctl enable mariadb

# systemctl start mariadb

 

Step 3: Set up RoundCube database

 

Like any other web application, RoundCube needs a separate database for its use. It also needs full permissions on that database. Now, while you could simply create the database and pass on the root credentials to the app, it’s not a good idea.

 

Instead, we suggest you create new MariaDB user for RoundCube and assign to it all the needed permissions. Here’s how to do it:

 

# mysql -u root -p

 

Enter the password when prompted (it’s the same password that you specified during MariaDB setup). And yes, it’s ironic that the command to run MariaDB is still `mysql` even though the project has now diverged.

 

Once you’ve connected to MariaDB, it’s time to create the new database:

 

mysql> create database roundcube;

 

You can name your database pretty much anything you want, but why not keep things as logical as possible? Then it’s time to create a new user. Make sure you pass in a strong password. We use ‘password’ here just for demonstration purposes.

 

mysql> create user ’roundcuber’@’localhost’ identified by ‘password’;

 

Why the ‘@localhost’ part? That’s because we want the database to be accessible only from the local machine. If someone ever happens to lay hands on the user’s DB credentials, they still won’t be able to access the database because this setting requires the user to be logged into the web server. That’s another neat little security check there!

 

And now, make this newly created user lord over the RoundCube database:

 

mysql> grant all privileges on roundcube.* to ’roundcuber’@’localhost’ identified by ‘password’;

 

The ‘.*’ part refers to all the tables (present and future ones) inside the database.

 

And finally:

 

mysql> flush privileges;

 

This is required so that the privileges tables inside MariaDB are updated and it becomes aware of new permission changes.

 

Step 4: Install RoundCube

 

Finally, what we’ve all been waiting for! Installing RoundCube webmail on CentOS 7. With all the preparatory hard work behind us, the first thing we need to do here is install all the necessary packages to enable our CentOS 7 system to run RoundCube:

 

# yum install php php-common php-json php-xml php-mbstring php-imap php-pear-DB php-mysql

 

Now it’s time to download the RoundCube package and install it:

 

# wget http://nchc.dl.sourceforge.net/project/roundcubemail/roundcubemail/1.1.3/roundcubemail-1.1.3-complete.tar.gz

# tar -zxpvf roundcubemail-1.1.3-complete.tar.gz -C /usr/share/nginx/roundcube

# mv roundcubemail-1.1.3 roundcube

# systemctl restart nginx

 

Here we extracted the RoundCube package and renamed the resulting directory to ’roundcube’, just to simplify things. We then move to inside Nginx’s directory and restart Nginx.

 

With this, you’re ready to set up things!

 

Step 5: Set up and install RoundCube webmail

 

All you now need to do is visit the URL http://myserver.com/roundcube/installer (replace the ‘myserver.com’ part with your server name, or with ‘localhost’ if you’re installing locally) and a graphical install guide will appear (much like the WordPress’s famous give-minute installation).

 

Follow the instructions on the screen, and soon you’ll be done. Finally, to access RoundCube webmail, visit http://myserver.com/roundcube.


Posted

in

by

Tags: