Home » How to install roundcube with nginx, postfix, and dovecot

How to install roundcube with nginx, postfix, and dovecot

This tutorial will walk through the steps how to install roundcube with nginx, postfix, and dovecot. This is basically like setting up your own private Google Apps, but it’s all free and managed by yourself. I won’t be walking through all the nuances of making sure your server isn’t marked as spam, blacklisted, and all that other jargon because that’s a tutorial in and of itself. You basically should Google how to setup reverse DNS entries and configuring your server for sending email after you’re done with this tutorial.

Let’s start by installing and enabling postfix and Dovecot:

Now we can download Roundcube. Go to http://roundcube.net/download and click their latest “complete” download link. It will take you to sourceforge – from there you can right click the “direct link” and click “Copy link URL” so you can paste this directly into your terminal to download with wget:

I chose to setup a webmail.yoursite.com type of subdomain in an nginx config. Here’s the file I placed in /etc/nginx/conf.d/webmail.yoursite.conf – feel free to change this to your liking:

Add the following to the bottom of /etc/nginx/fastcgi_params:

Setup your MySQL database:

Test and reload nginx:

Edit /etc/php.ini and set your date.timezone setting (I’m using America/New_York):

Edit /etc/dovecot/dovecot.conf

Uncomment line 24:

Uncomment and modify line 30:

Edit /etc/dovecot/conf.d/10-auth.conf

Uncomment and change line 10:

Modify line 100:

Edit /etc/dovecot/conf.d/10-mail.conf

Uncomment and modify line 30:

Edit /etc/dovecot/conf.d/10-master.conf

Uncomment and modify lines 96-98:

Edit /etc/dovecot/conf.d/10-ssl.conf

Uncomment and modify line 8:

Restart dovecot:

Change permissions of logs and temp directories:

Now point your hosts file or DNS record for webmail.yoursite.com at your server, and go to http://webmail.yoursite.com/installer in your browser. You should now be able to walk through the installer pretty easily without many questions. The steps above should have resolved the extra things I had to do during the installer process so this should be good to go!

Don’t forget to click the button that initializes the database on page 3 of the installer. If you’re interested in setting up DKIM signatures, then I’d recommend reading Steve Jenkin’s post on this. Thank you Steve for your hard work getting the OpenDKIM package to be available in EPEL!

Please post any questions, comments, or issues in the comments below and I’ll help you troubleshoot your issues 🙂

17 comments on “How to install roundcube with nginx, postfix, and dovecot

    • Jeff Hays on

      Hey Ricky,

      It’s always great to hear that one of my posts was helpful! Yes, you should be able to install and configure OpenDKIM (thanks to Steve Jenkins’ package for CentOS 7). I’d recommend using his post to set it up – I couldn’t have written it better myself.

  1. Soldier on


    Great tutorial eve the best, the installation and configuration work very well but I have a doubt… how I can create mail accounts to login? Because once finished the installation and if I open the webmail url is requested the username and password but I don’t have any email account yet.

    Thanks in advance!

  2. Soldier on

    Btw, I don’t want to use my mail service with Google Apps, I want to use as just a mail server because I need to use this with my Laravel Project so I don’t know how to configure the smtp mail server and I want to know how to create the email accounts to start using.

    Thank you!

  3. Alex on

    Hi. Thanks for the tutorial. I followed every step and when I try to open http://webmail.yoursite.com/installer i get this:

    An error occurred.

    Sorry, the page you are looking for is currently unavailable.
    Please try again later.

    If you are the system administrator of this resource then you should check the error log for details.

    Faithfully yours, nginx.

    I checked the error.log and it says this:

    *11 connect() to unix:/var/run/php-fpm/www.sock failed (2: No such file or directory) while connecting to upstream, client….

    There’s no http://www.sock file in that address. what’s is it? Can you plz help me to fix my problem? Thanks

  4. nekoizmase on

    Hi Jeff 🙂

    I have followed your tutorial and got the similar problem as Alex – when I navigate to my site I got message>
    An error occurred.

    Sorry, the page you are looking for is currently unavailable.
    Please try again later.

    If you are the system administrator of this resource then you should check the error log for details.

    Faithfully yours, nginx.

    But I don’t have anything in my nginx error log.
    The problem begins when I add subdomain to sites-enabled.

    (you placed it in /etc/nginx/conf.d/webmail.yoursite.conf – but I read that I have it also at sites-available and create symbolic link to sites-enabled)

    So, I don’t understand where the problem is. In my /var/www/ I have directory which contains my website, and in nginx conf its root is /var/www/site-name
    Roundcube is also in /var/www/roundcube (sybmolic link actually to /usr/share/roundcube) so, I sat root for subdomain conf webmail.mysite.conf like this, but when I add it to sites-enabled I can’t see neither my site nor roundcube.

    Can you help me please, I have been stuck there for a long time 🙁

  5. Jeff Hays on

    Hi nekoizmase,

    It sounds like the problem you’re having is actually with your virtual host configs in nginx. Judging by your directory structure it sounds like you’re on an Ubuntu or Debian based system. It would be tough to tell you exactly how to solve your issue without seeing it myself, but I find that it’s always helpful to setup your virtual hosts to have a custom log file for error and access logs.

    You should be able to check the global logs as well which are typically found in /var/log/nginx/error.log – check to see if that has some errors about a path not found, or just do tail -f /var/log/nginx/access.log and refresh the page in your browser to see if it’s even hitting your server.

    If none of this sheds any light on your problem, feel free to post back with more detail.

    Hopefully this helps. Cheers!

    • Jeff Hays on

      Hey Miticcio,

      “Access Denied” errors (assuming it’s a 403 response) are typically when the web server either cannot access the directory that the webmail files are served from (this could be permissions, ownership of the directory, parent directories, nginx/Apache rules restricting access, etc.).

      If you’re using an RHEL distribution like CentOS or Red Hat Enterprise Linux, you may want to check selinux settings (disabling it would be a good test of selinux-related issues). You can also check to see if the user nginx/Apache/etc. is running as, login as (or switch to) that user, and verify that you can access the /usr/share/roundcube directory. If you can list the files in that directory as the user that your web server runs as, then the issue is somewhere else. Keep in mind that nginx and many other web servers will require +x on all directories in order for it to change directories and serve your content.


Leave a Reply

Your email address will not be published. Required fields are marked *