Tricks to migrate from DotClear 2 to WordPress 3

As I spoke about in the previous post, this blog now runs smoothly using the WordPress engine.

In this post, I'm going to give you some tricks / to-do, in case you ever want to migrate too, from the DotClear platform.

Installation of the software

The OS of the server is a Debian Squeeze. I've updated sources.list to add the repository from DotDeb, so I could get the newest packages of PHP, MySQL and Nginx. This is pretty straightforward, you just need to follow the instructions 🙂

  • Nginx (or a simple apt-get install nginx using dotdeb if you don't want the latest development version)
  • PHP-FPM : sudo apt-get install php5-fpm
  • APC

The configuration of PHP-FPM is easy: I've only updated the www.conf file, located in /etc/php5/fpm/pools.d/, and replaced the value of the listen parameter to: /var/run/php-fpm.sock.
The configuration of APC has been given in this link already.

Nginx setup

This had been the trickiest part of the configuration for me. But here are the rules which used to work for me:

Follow this site, for the basic configuration of nginx. In my case, I have used the General WP rules, as my blog is not located in a sub-folder, or a sub-domain. I've kept the site configuration file, which itself includes the restrictions.conf and wordpress.conf files. I did not use the cache configuration file yet. But later, you will know why.
You don't have to forget to update this section accordingly to the path of the socket file you had used in the configuration file of PHP5-FPM.

[code lang="plain"]upstream php {
server unix:/tmp/php-fpm.sock;

W3C total cache

The installation of the plugin is very simple, as you need to do that inside of the administration panel of WP. The plugin will complain that URL rewriting is not activated.

To fix this issue, you will need to copy the nginx configuration file that the plugin gives to you, and paste it in a new file in /etc/nginx/global/wordpress-w3-total-cache.conf, and include this file in the wordpress.conf file you have created the step just before. (In other words, you replace the content of the w3-total-cache nginx configuration given by this site, by the content of what the plugin gives you.)

You need to restart Nginx, and everything should run smoothly.

Importing DotClear data

This step was by far the most annoying. There are a few blog posts of people who claimed to have succeeded in the enterprise of migrating their data from DC to WP, but to be honest, it was a pain for me, for one reason: the import plugin in WP sucks. A lot 😀

So to avoid to loose too much time in the migration, here are a few advices which may help you.

Convert all your DC posts in XHTML. I did that by hand, because I don't have too much posts. But this may be a pain, so maybe a PHP script already exists to automatically do that for you. To be honest, I did not search.

Once you have installed the dotclear import plugin in WP (yes, you still need this one), the first thing to do is to update it, because it references invalid columns of the DC database schema. You can download my copy here. After you edited the file, you can import your data.

The next step for me was to update all the posts, to convert the tags used by the SyntaxeHL plugin of DotClear (for the code syntax coloring), so they are compatible with the SYntaxeHighlighter plugin of WP. I have made available another script which will do that for you.

Next, you have to refresh the number of comments for each post. Indeed, the import plugin did import the comments, associated them with the posts, but it did not do everything it needed to make the number of comments for each post correct. I could find an already made script on internet, so feel free to use it ^^

Unfortunately, despite the categories have been correctly imported, I had to assign them to each post. And more painful, I also had to edit each post individually to put the tags, because they were not imported 😐 And even more painful, I had to edit once again each post, to fix the code snippets, because the end of lines had been lost in the process :'(

Hopefully, I only had 83 posts at the time of the migration. But I didn't update all the posts anyway, only the most recent ones.

The very last step was to create a new rewriting rule for nginx, to make the URLs of the RSS feeds of my old DotClear blog be still usable. The RSS of my old blog was accessible using this URL: But now, the WP blog is located in the root of the server folder. Then, I had to add this rewriting rule in the file (in /etc/nginx/sites-enabled), just before the server section ends:

[code lang="plain"]rewrite ^/blog(.*)$ $scheme://$server_name$1 last;[/code]

Finally, we are at the end of the process. I'm pretty happy I did not decide to migrate to WP later. It was a painful process. First, because of the import plugin which lacks a few important features, and also because of the configuration of nginx, which gave me some hard times ^^

Anyways, everything is running fine, and the reactivity seems to be great, thanks to the various tools I use to speed things up (APC / PHP-FPM / W3 Cache / CloudFlare). The blog still lacks a few minor things, but it's going to evolve slowly the next few days / weeks.

I hope this post will help some of you who may choose to take the WP train, and will save them a few hours of scratching their head, wondering why it doesn't work 🙂

Happy coding!