Roundcube is a free and open-source, fully-featured web-based multilingual IMAP webmail software, with an application-like user interface that is fully functional and customizable, and uses the latest web standards. It is built using PHP and offers full functionality that you can expect from a modern email client.
Roundcube Features:
- It’s multilingual, supports over 70 languages.
- Supports a Find-as-you-type address book.
- Supports multiple sender identities.
- Offers sophisticated privacy protection.
- Has a full-featured address book with groups and LDAP connectors.
- Offers richtext/HTML message composing.
- Supports searching for messages and contacts.
- Supports Int. domain names (IDNA).
- Supports folder manipulation, shared folders, and ACL.
- Extensible using the Plug-in API.
- Provides spell checking functionality.
- Provides import/export functions.
- Has a plug-in API for flexible extensions and so much more.
Recommended System Requirements:
- A CentOS 8/RHEL 8 or CentOS 7/RHEL 7 Server with Minimal Install.
- Apache or Nginx webserver
- PHP and MySQL/MariaDB database
- SMTP and IMAP server with IMAP4 rev1 support
For the scope of this article, we assume that you already have a running Postfix email server with virtual users, otherwise, follow our guides setup:
- Setting Up Postfix Mail Server and Dovecot with MariaDB – Part 1
- Configure Postfix and Dovecot Virtual Domain Users – Part 2
- Install and Integrate ClamAV and SpamAssassin to Postfix Mail Server – Part 3
Testing Environment:
For the purpose of this article, I will be installing Roundcube Webmail on a Linode CentOS VPS with an Nginx web server, static IP address 192.168.0.100, and hostname mail.tecmint.com.
Step 1: Install Nginx, PHP-FPM, and MariaDB in CentOS 8/7
1. First start by enabling EPEL and REMI repositories and install Nginx, PHP, PHP-FPM, and MariaDB server on your CentOS system.
# yum install epel-release # yum install http://rpms.remirepo.net/enterprise/remi-release-8.rpm [CentOS/RHEL 8] # yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm [CentOS/RHEL 7] # yum install yum-utils # yum-config-manager --enable remi-php72 # yum install nginx php php-fpm php-mcrypt php-cli php-gd php-curl php-xml php-mysql php-mbstring php-pspell php-imagick mariadb-server
2. Once you have successfully installed all the packages, start the Nginx web server, enable it to auto-start at boot time and check if its up and running.
# systemctl start nginx # systemctl enable nginx # systemctl status nginx
3. Next, if you have a system firewall enabled, you need to open port 80 for external requests.
# firewall-cmd --permanent --add-port=80/tcp # firewall-cmd --reload
4. Next, you need to configure PHP-FPM to work properly. Open the file /etc/php.ini using a command-line test editor.
# vim /etc/php.ini
Look for the directive ;cgi.fix_pathinfo=1
, uncomment it and set its value to 0.
cgi.fix_pathinfo=0
Also, uncomment the directive ;date.timezone
and set its value to your timezone.
date.timezone = "Africa/Kampala"
Once you are done, save the file and exit.
5. Then start PHP-FPM service, enable it to auto-start at boot time, and check if it is up and running, as follows.
# systemctl start php-fpm # systemctl enable php-fpm # systemctl status php-fpm
Step 2: Secure MariaDB Server and Create Roundecube Database
6. Now start the MariaDB service using the following commands.
# systemctl start mariadb # systemctl enable mariadb # systemctl status mariadb
7. The default MariaDB installation is unsecure. You need to run the security script which comes with the binary package, to secure it. You will be asked to set a root password, remove anonymous users, disable root login remotely, and remove the test database.
# mysql_secure_installation
8. Now login to the MariaDB database, create a database for Roundecube, and grant the user to appropriate permissions on the database (remember to set a strong/secure password in a production environment).
# mysql -u root -p MariaDB [(none)]> CREATE DATABASE roundcubemail /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */; MariaDB [(none)]> CREATE USER 'roundcube'@'localhost' IDENTIFIED BY '=213@!#webL'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcube'@'localhost'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit
9. Next, import the Roundcube table layout to the newly created database.
# cd /var/www/html/roundcubemail/ # mysql -u root -p roundcubemail < SQL/mysql.initial.sql
Step 3: Download Roundcube Package
10. In this step, download the latest stable version (1.4.9 at the time of this writing) of Roundcube from the download page or use wget command-line downloader to get it, extract the TAR file, and upload the files into your web server document root.
# wget -c https://github.com/roundcube/roundcubemail/releases/download/1.4.9/roundcubemail-1.4.9-complete.tar.gz # tar xzf roundcubemail-1.4.9-complete.tar.gz # mv roundcubemail-1.4.9 /var/www/html/roundcubemail
11. Next, set the appropriate permissions on the Roundcube webroot files.
# chown -R nginx:nginx /var/www/html/roundcubemail
Step 4: Configure Nginx Server Block For Roundcube Web Installer
12. Now create an Nginx server block for the Roundcube under /etc/nginx/conf.d/ (you can name the file the way you want but it should have a .conf extension).
# vim /etc/nginx/conf.d/mail.example.com.conf
Add the following configuration in the file.
server { listen 80; server_name mail.example.com; root /var/www/html/roundcubemail; index index.php index.html; #i# Logging access_log /var/log/nginx/mail.example.com_access_log; error_log /var/log/nginx/mail.example.com_error_log; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } location ~ ^/(README.md|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ { deny all; } location ~ ^/(config|temp|logs)/ { deny all; } location ~ /\. { deny all; access_log off; log_not_found off; } location ~ \.php$ { include /etc/nginx/fastcgi_params; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
Save the file and close it.
13. Next, open the file /etc/php-fpm.d/www.conf to make a few changes to PHP-FPM web directive.
# vim /etc/php-fpm.d/www.conf
Change the user apache to nginx in the following variables.
user = nginx group = nginx
Then comment out the line listen = 127.0.0.1:9000 and set the listen variable to listen on a Unix socket set in the nginx server block file:
listen = /var/run/php-fpm/php-fpm.sock
Also, set the permissions for UNIX socket, uncomment and change the lines to:
listen.owner = nginx listen.group = nginx listen.mode = 0660
Once you are done, save the file and close it.
14. Then restart the Nginx and PHP-FPM services to apply the recent changes, as follows.
# systemctl restart nginx php-fpm
Step 5: Access Roundcube Web UI
15. Before you start the install wizard, to avoid any session errors, set the appropriate permissions on the directory /var/lib/php/session/. The default group owner is apache, change it to nginx as shown.
# ls -ld /var/lib/php/session/ # chown :nginx /var/lib/php/session/ # ls -ld /var/lib/php/session/
16. Now open a browser and use the address http://mail.example.com/installer
(replace domain with the server name you set while creating an Nginx server block for Roundcube) to access the web installer. If all PHP versions, extensions, and php.ini/.htaccess settings are correct, you will see the following screenshot, click on Next to go to the configurations page.
http://mail.example.com/installer OR http://IP-address/installer
17. The configurations page allows you to set up your Roundcube instance. We will only explain the important options for the scope of this guide.
Under the General Configuration, set a product_name for example Example.com Webmail.
Go to Database setup, enter the database host, name, user, and password to connect to the MySQL server.
Then scroll down to IMAP and SMTP settings and enter the IP address of your IMAP and SMTP server, if its the same server on which you are running Roundcube, leave it as “localhost” and also specify other necessary parameters.
You can specify other settings according to your needs, once you are done, click on Create Config.
18. You should now see a message saying ”The config file was saved successfully into /var/www/html/roundcubemail/config directory of your Roundcube installation.” Click on Continue.
19. You can review your configuration from the Test config page as shown in the following screenshot.
20. Next, remove the whole installer folder (which contains files that may expose sensitive configuration data like server passwords and encryption keys to the public) from the Roundcube root directory (or make sure that the enable_installer option in config.inc.php is disabled).
# rm -rf /var/www/html/roundcubemail/installer
21. Finally, use the URL http://mail.example.com to access the Roundcube login page. Enter your user name and password to view your mails.
Summary
Roundcube is a widely used, fully-featured web-based multilingual mail client. In this article, we showed how to install the latest stable version of Roundcube Webmail on a CentOS/RHEL 8/7 with the Nginx web server. If you have any questions, use the feedback form below to reach us.
Hi,
Thanks for article, but I am getting below error.
504 Gateway Time-out
Dear Admin
Reference Step 5. Unable to access
http://mail.example.com/installer
. I configured nginx.conf to use /var/www/html/ but i am getting 403 forbidden.What do I do next?
Thanks
@Hoang,
Seems issue with your Nginx server block file – mail.example.com.conf. Please check the nginx server logs to troubleshoot the error…
Hi everyone! I follow all steps, but when I access to
/installer
it shows 403 forbidden.How can I fix it?
Thanks!
When import the roundcube table layout to the newly created database:
I get error -bash: SQL/mysql.initial.sql: No such file or directory
Can anyone help me?
@chardo
Ensure that you have run the command within the Roundcube installation directory, you can try this:
I think this step is after you do the wget, to get this folder first.
Anyone has seen this and knows how to go around?
Something has triggered a missing webpage on your website. This is the default 404 error page for nginx that is distributed with Fedora. It is located /usr/share/nginx/html/404.html
You should customize this error page for your own site or edit the
error_page
directive in the nginx configuration file /etc/nginx/nginx.conf.I have a 502 bad gateway when i tried to go to mail.example.com/installer.
@Pierre
This means that either:
Nginx can’t connect with the upstream server, the PHP-FPM process, so check this
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
in your server block config.OR the HTTP service port 80 or HTTPS(443) is blocked in firewall.
Try to view the Nginx logs: /var/log/nginx/error.log using cat or tail command.
Hi,
On my server Postfix (SMTP) and roundcube (IMAP) is install and running properly, but at certain instant of time ( say 1 in 50 attempts) when a user login to webmail (roundcube) then it show a error of “no input file” what could be the problem?
Can anyone give me complete guide, how can i resolve this problem…
Hello, I have a question. Why exactly Nginx? Why not Apache?
@Anton,
Its your choice which web server to choose, you can for Nginx if you want..
Thanks for your answer. What do you recommend? And what is the fundamental difference between Apache and Nginx as a web server for roundcube?
@Anton,
I would recommend Nginx over Apache, as nginx provides better performance than Apache.
Reference Step 5. Unable to access
http://mail.example.com/installer
. I configured nginx.conf to use /var/www/html/ but i am getting 403 forbidden.@Zainab
Check the value of the root parameter in the nginx config, in the example config, its:
root /var/www/html/roundcubemail;
You are seeing the error because nginx can’t find an index file in the configured root, or due to permissions issues.
thank you..it worked.
@Zainab
Great, thanks for the feedback.
I am having the same issue but have check the above and it still shows 403 Forbidden.
Hi ! thank for all.
I have problem when i try to open mail.exemple.com from mozilla show that the site not exist.
Help me please..
@Balbaki
Ensure that you have created a Nginx server block for the Roundcube under /etc/nginx/conf.d/ and configured it very well to serve requests using the address mail.example.com.
Very helpful thanks
If you can please correct the typo: listen = /var/run/php/php-fpm.sock — should be: listen = /var/run/php-fpm/php-fpm.sock as php-fpm did not start for me otherwise.
@Andrea,
Thanks for notifying that typo, yes it should be
listen = /var/run/php-fpm/php-fpm.sock as php-fpm
, corrected in the article.A nice summary! I made my own preferential changes and installed Fedora RPMs but otherwise it was good!
Thanks!
@Philip
Okay, many thanks for the feedback.