Upgrading Redmine from 0.9.x to 1.3.x

Upgrading Redmine from 0.9.x to 1.3.x

Today i was asked by a client to upgrade his Redmine setup from version 0.9.3 to the latest stable version. As his server is running Ubuntu 10.04 LTS and he installed Redmine using the Ubuntu repositories, this wasn’t the easiest or smoothest task i’ve ever done.

I suspected that upgrading from 0.9.3 directly to 1.3-stable would be a nightmare, so i was planning on upgrading to 1.0-stable, then to 1.1-stable, then 1.2-stable and finally 1.3-stable.

All looked well, and i started taking backups. Of course, the whole Redmine installation was setup using the Ubuntu repositories, so clearly, all of the ruby, rails, rake and rubygems packages were from Ubuntu 10.04. Which would cause a bit of a problem, as i needed newer versions of certain packages. So i ran the following commands (after taking backups of course.) to remove redmine and all it’s dependencies and reinstall whatever is necessary to run rubygems, rake and libapache2-mod-passenger.

This made sure i had a basic setup. After that i used svn to get all the versions

This gave me the opportunity to just go into the appropriate directory, follow the guide on on how to upgrade and do that for each major release. On occasion rake would throw me an exception stating i needed a gem installed or a newer version installed, but overall that wasn’t a real problem. Just make sure you run

This all went good until i got to the point of upgrading to 1.3. Apparently version 1.3 needs a later release off rubygems. Whenever i tried running rake to do the db migration, i ended up getting the following error:

This is a little problematic as the Ubuntu 10.04 LTS repository does not allow for a newer version to be installed from it. My solution was to just get the package from a newer distribution using a backport available thanks to a Ubuntu PPA from Mackenzie Morgan (Thanks!):

This installs a version which can be used by Redmine 1.3-stable. After that, everything looked great, i could log in, i checked the configuration and it worked!

Or i thought… Whenever i opened the issues list of the project, i would get a Server error (500), the log reflected this:

Googling the error returned me to a bug report from version 1.0, which presented me with a simple solution, i just had to run a simple query on the database:

Ubuntu 11.10 boot problem

Ubuntu 11.10 boot problem

Today i had a network issue on my system, so i tried rebooting my Ubuntu 11.10 server which acts like a router, firewall, DHCP and DNS server for my network. Turns out there was a rather big problem with Ubuntu 11.10 if you upgraded from a previous version.

It seems that in Ubuntu 11.10 the directory containing running processes information and lock files has changed, or well, it has for certain programs. This results in a system where certain daemons/programs expect to find sockets in /var/run, while they are present in /run, or vice versa.

This might result in a boot problem looking like this:

The first lines are not so important, what is important are the last two. It says:

After that last one, you might get that it waits for another 60 seconds for network configuration, but it will get stuck in boot after that.

Luckily i had my 3G enabled phone close, so i could do some searching, which gave me a link to a bug report and a forum post with a fix. In short, few simple steps can help you out here:

  1. reboot into recovery mode
  2. start a root shell
  3. mount the filesystem as read/write:
  4. move everything from /var/run into /run:
  5. move /var/lock into /run:
  6. create symlinks from /var/run to /run and /var/run/lock to /var/lock:
  7. reboot

Worked like charm here. Hope this helps.

PHP 5.3.2 DateTime diff() issue

PHP 5.3.2 DateTime diff() issue

It seems that PHP 5.3.2 ( 5.3.2-1ubuntu4.10 ) has a small issue when using the DateTime diff() method.

Got this code:

This code results in:

It seems the diff statement changes the starting date to a date before. This is kind of an issue, i need that difference in a project between days, weeks, months and even years. And the issue get’s worse if you use weeks (the difference becomes 14 days instead of 7) in the interval or months (61 instead of 30 or 31). So i decided to use a quickfix to calculate the difference, cause this was not working…

The workaround needed to change depending on the mode variable (day, week, month or year). For day and week it could just be 1 and 7 days, but the amount of days in a month and years changes per month and per year (leap years). So i came up with:

I decided to use the mktime function, because the getTimestamp() gave some issues concerning timezones (i think ;))


Dries Verachtert pointed me to a comment on the page of the DateTime sub method. The short of it:

If you use diff() after sub(), the effects of the sub() will be repeated on the date object.
It doesn’t matter if the object is the one diffed or doing the diffing (i.e. which object you call diff() from).
Note that using add() instead of sub() does NOT have the same effect.
This is particularly undesirable — in this example you make a datetime, use sub() to make it a relative time in the past, and then date->diff() to confirm the difference. But the diff() inadvertendly makes the difference 2x.

Strange issue, but i can tell you it’s fixed in 5.3.3, as i have running that on an internal test server, and the code does a perfect job on that.

Setting up a new VPS

Setting up a new VPS

Today i decided to get a new VPS from Shift to the cloud, a new project from Stone Internet Services (@stoneis). Stone IS has been a choice for webhosting and domain registration for me and my clients for years, and i have always been happy with their service.

In the past i have always counted on ULYSSIS for my personal hosting, as i have been vice-president of this organisation and have a free account because of that. But lately, i realized that, although their service is incredible for an organization of volunteers, it is not as open and free as having an own server at your disposal.

Ordering the server was rather easy, i only had an issue with the payment system, but i hope it was just a fluke and not something others experience. At least the service desk helped me out pretty quick. I opened an issue last night and it was fixed by the time i woke up this morning, on a Saturday.

After i got the base VM (Ubuntu 10.04 LTS) running i started to configure it by installing some base packages like apache, openssl, php5, suphp, … After a while i noticed it didn’t have the promised IPv6 address, so i opened another support ticket, and it took them about 15 minutes to fix it. If that’s an indication of response time for the Best Effort SLA, i am impressed.

When the IPv6 address was enabled, i did get into trouble with Apache. Everytime i wanted to start it, it crashed with the following error:

Whenever i disabled SSL, it worked fine. After a few google searches, i came to the conclusion that the automatically generated SSL certificates became invalid with the change of network interfaces/addresses. I fixed that quickly by creating a new certificate, and my own Certificate Authority . If you need some info on how to do that, you can find a good tutorial on the website of Paul Bramscher.

And now that this blog is moved to the server, we’ll see how it goes. Next step will be to move my Symfony2 project from my development environment (VM on a personal vSphere setup on two local servers) to this server, so i can more easily access it from anywhere.

Other plans include setting up a monitoring system (Nagios) to monitor my internal network and some servers and environments of my smaller clients (who do not have the resources to implement it locally). This kind of monitoring system is already running on my local vSphere farm, but that means it uses my personal internet connection, which is just a commercial connection (once or twice a month it goes down in the middle of the night for 10-15 minutes).