Company dedicated to web development, graphic design, photography and web hosting.

How to install roundcube
Published Monday, 9th of December 2013
Overview We can install a single copy of roundcube for all our users in the web server keeping out the installation from their users' folder. It gives more security, uses less disk space and makes easier updates. The installation was done in Debian 7.0 with Apache 2.2, PHP 5.4 and MySQL 5.5Steps to follow Installation
  1. Notice that we need root access for all the commands in this blog entry.
    First at all we need to create the folder where our roundcube code will be stored:
    mkdir /usr/share/roundcube
    cd /usr/share/roundcube

  2. Download the latest version from the web of roundcube and uncompress in the current directory. Delete later the downloaded file because is not needed anymore:
    wget http://downloads.sourceforge.net/project/roundcubemail/roundcubemail/0.9.5/roundcubemail-0.9.5.tar.gz
    tar -zxvf roundcubemail-0.9.5.tar.gz
    rm roundcubemail-0.9.5.tar.gz
Configure apache
  1. We will force the owner and group of all the files to root and also allow read and write for any other process. It's needed because if we execute apache files under fastcgi, the user will be the owner of the site and it will not be root. Usually, for security reasons, every user in apache is under his own group so if you want to give access to this folder to some group only you should add every apache user to such group.
    chown root:root -R /usr/share/roundcube
    chmod 777 -R temp/
    chmod 777 -R logs/
  2. We will configure now apache to serve our folder. Create the folder for roundcube apache configuration:
    mkdir /etc/roundcube
    We will create and modify the file to use:
    vi /etc/roundcube/apache.conf
    And add the next lines.
    123456789101112131415161718192021
    Alias /webmail /usr/share/roundcube
    <Directory /usr/share/roundcube>
        Options -Indexes
        AllowOverride All
    </Directory>
    <Directory /usr/share/roundcube/config>
        Order Deny,Allow
        Deny from All
    </Directory>
    <Directory /usr/share/roundcube/temp>
        Order Deny,Allow
        Deny from All
    </Directory>
    <Directory /usr/share/roundcube/logs>
        Order Deny,Allow
        Deny from All
    </Directory>
    In the file we have created an alias to point to our folder, and secure the folders config, temp and logs to avoid any access.
  3. Now we add our configuration file for apache to the list of files that apache will load:
    cd /etc/apache2/conf.d
    ln -s ../../roundcube/apache.conf roundcube.conf
Configure mysql
  1. We need to create an user and a database where roundcube will sotre the configuration per user (contact lists, signatures, configuration, etc.). Open mysql command line (it will ask for your root password):
    mysql -uroot -p
    In the mysql prompt, execute all the next commands one by one. The text 'mypassword' in the next lines should be replaced for the password that you want to assign to the user roundcube:
    mysql> USE mysql;
    mysql> CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'mypassword';
    mysql> GRANT USAGE ON * . * TO 'roundcube'@'localhost' IDENTIFIED BY 'mypassword';
    mysql> CREATE DATABASE IF NOT EXISTS `roundcube`;
    mysql> GRANT ALL PRIVILEGES ON `roundcube` . * TO 'roundcube'@'localhost';
    mysql> FLUSH PRIVILEGES;
    mysql> USE roundcube;
    mysql> SOURCE /usr/share/roundcube/SQL/mysql.initial.sql
    It creates the user roundcube, the database roundcube and give permissions for the user to the database. Finally, executes the initial script needed to create all the tables and initial data. The script is provided by the roundcube installation.
Configure roundcube
  1. Now we need to configure roundcube parameters. Go to the roundcube configuration folder and make a copy of the distribution configuration file.
    cd config
    cp main.inc.php.dist main.inc.php
    Modify options in the file main.inc.php. Most of them are just personal preferences. Choose the one that better fit your services or meet client preferences.
  2. Do the same with the database configuration file.
    cp db.inc.php.dist db.inc.php
    In that case you need to change the DSN string connection to allow roundcube connect with the user previously created to the database that we have created for such purpose.
Enable roundcube
  1. Finally we can enable the installation to the users in our server. First remove all the files not needed anymore deleting the folder installer:
    rm -rf /usr/share/roundcube/installer
    And restart apache to reload the roundcube configuration, enable the alias and allow access to the folder:
    /etc/init.d/apache restart
References http://www.roundcube.net/



Back to the list of entries