The Roundcube development team has released a new version of the webmail platform. New features include threaded message lists and address groups. Upgrading roundcube to version 0.4 isfairly straight forward.

Before continuing, make sure you have a current backup of your mysql database and your webserver. You need to download the latest code from the Roundcube site.

Extract the archive into the Document root of your Apache installation, in our case /Library/WebServer/Documents.

Step into the newly created directory and change the permissions on the temp and logs directory so that the webserver can write into these directories with the following commands:

cd /Library/WebServer/Documents/roundcubemail-0.4
sudo chown -R www:www temp
sudo chown -R www:www logs

Next we need to update the database structure for Roundcube-0.4. Start up MySQL on the command line as the roundcube user with this command:

mysql -u roundcube -p

Note: you will need to enter the password you chose for roundcube when you initially installed it. (if you have forgotten it can be found in the config/db.ini.php file of your old roundcubemail installation). If you have a different database name, use that instead of “roundcubemail”

If your upgrading from roundcubemail version 3.0-stable, run the following commands in the mysql shell:

USE roundcubemail
TRUNCATE `messages`;
ALTER TABLE `messages`
ADD INDEX `index_index` (`user_id`, `cache_key`, `idx`);
ALTER TABLE `session`
CHANGE `vars` `vars` MEDIUMTEXT NOT NULL;
ALTER TABLE `contacts`
ADD INDEX `user_contacts_index` (`user_id`,`email`);
quit

If your upgrading from roundcubemail version 3.1-dep, run the following commands in the mysql shell:

USE roundcubemail
ALTER TABLE `messages` DROP FOREIGN KEY `user_id_fk_messages`;
ALTER TABLE `cache` DROP FOREIGN KEY `user_id_fk_cache`;
ALTER TABLE `contacts` DROP FOREIGN KEY `user_id_fk_contacts`;
ALTER TABLE `identities` DROP FOREIGN KEY `user_id_fk_identities`;
ALTER TABLE `messages` ADD CONSTRAINT `user_id_fk_messages` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `cache` ADD CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `contacts` ADD CONSTRAINT `user_id_fk_contacts` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `identities` ADD CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `contacts` ALTER `name` SET DEFAULT ”;
ALTER TABLE `contacts` ALTER `firstname` SET DEFAULT ”;
ALTER TABLE `contacts` ALTER `surname` SET DEFAULT ”;
ALTER TABLE `identities` ADD INDEX `user_identities_index` (`user_id`, `del`);
ALTER TABLE `identities` ADD `changed` datetime NOT NULL DEFAULT ’1000-01-01 00:00:00′ AFTER `user_id`;
 
CREATE TABLE `contactgroups` (
  `contactgroup_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int(10) UNSIGNED NOT NULL DEFAULT ’0′,
  `changed` datetime NOT NULL DEFAULT ’1000-01-01 00:00:00′,
  `del` tinyint(1) NOT NULL DEFAULT ’0′,
  `name` varchar(128) NOT NULL DEFAULT ”,
  PRIMARY KEY(`contactgroup_id`),
  CONSTRAINT `user_id_fk_contactgroups` FOREIGN KEY (`user_id`)
  REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  INDEX `contactgroups_user_index` (`user_id`,`del`)
);
 
CREATE TABLE `contactgroupmembers` (
  `contactgroup_id` int(10) UNSIGNED NOT NULL,
  `contact_id` int(10) UNSIGNED NOT NULL DEFAULT ’0′,
  `created` datetime NOT NULL DEFAULT ’1000-01-01 00:00:00′,
  PRIMARY KEY (`contactgroup_id`, `contact_id`),
  CONSTRAINT `contactgroup_id_fk_contactgroups` FOREIGN KEY (`contactgroup_id`)
  REFERENCES `contactgroups`(`contactgroup_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contact_id_fk_contacts` FOREIGN KEY (`contact_id`)
  REFERENCES `contacts`(`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
 
quit

The next step is a lot simpler. Point your browser to http://yourhostname/roundcubemail-0.4/installer/ and follow the instructions, just like you did when you initially installed roundcubemail.

In step 2 make sure you enter all the information as you did for the previous install of roundcubemail. Perhaps you had:

Database setup:
localhost
roundcubemail
roundcube
PASSWORD (or whatever you have it set too)
 
IMAP Settings:
ssl://localhost:993

If the installer was unable to create the config files you need to copy the contents located in the browser in the files db.inc.php and main.inc.php located in the directory config

If you have tested the setup and it works please remove the installer directory from the roundcube installation. It might be used by others to hack your installation.

For errors you could check the logfiles to explain what went wrong. For Roundcube errors check the /logs/errors file and for general mail errors check the /var/log/mail.log file.

Lastly, after you have checked that your new install is working properly, We need to change the symbolic link from our old installation to the new one. Then you can remove the previous version of roundcubemail from your webserver with:

sudo rm /Library/WebServer/Documents/roundcubemail
sudo ln -s /Library/WebServer/Documents/roundcubemail-0.4 /Library/WebServer/Documents/roundcubemail