Migrating from pMachine to WordPress
A few friends and acquaintances are still stuck on pMachine and are considering converting to WordPress. I wish I could tell you the conversion is as simple as installing WordPress itself. What follows are a few suggestions on how to go about it, though, that might ease your transition somewhat.
Preparation
- Go download two versions of WordPress:
- version 1.5.2 from the Release Archive
- The latest version from the Download page
- Download a copy of the pmachine import script,
import-pmachine23-03.phps. Since the original author of the script is redesigning their website at the moment, I had to download his file from Google’s cache—but I’ll save you the trouble and let you download it from me instead. You’ll have to change the extension from.phpsto.phpbefore you can execute it, of course. I have made one very minor change to this script to make it work with WordPress 1.5.2 as per these instructions; if you download this file from elsewhere you’ll have to make the same edit yourself (I won’t spoil the surprise about what it is). - Locate your host’s installation of PHPMyAdmin—a web-based tool for managing MySQL databases. If you don’t know where this is, you’ll have to talk to your hosting provider. If they don’t have one, you’re SOL unless you can set up a local webserver and MySQL database, which is (far) beyond the scope of this article.
- Make a backup of your pMachine database now. It takes seconds to do, and will consume only a few hundred kilobytes of hard drive space—but it will save you a world of heartache if something goes wrong during the migration process, or if you change your mind at some point in the future and want to revert back to pMachine. Skip this step at your own peril!
- Make a backup of your pMachine installation now. While only a few files will probably be replaced by WordPress, you should really just archive the whole thing and download it and start fresh. Even though you may not be using them, old files left on your web server are a security hazard; someone may find them and exploit a security hole in the software. Download an archive so you can revert back to pMachine if you need to later, and so you can find copies of anything you delete by accident cleaning up once WordPress is up and running.
- Optional: You may wish to disable your blog at this point—Specifically, you want to prevent people from making new entries, making comments on existing entries, or registering for new accounts. The reason is simple: Anything that happens after you’ve exported the database will not be converted to WordPress. It’s up to you how to handle this; if your blog is low-traffic you can probably leave it running while you work. On the other hand, if it’s high-traffic, or you expect the conversion to take you a while, you’re better off switching into maintenance mode until the conversion process is complete.
Installation
Now that you’ve downloaded everything you need, it’s time to install WordPress. We first need to install WordPress 1.5.2, because that is the last version of WordPress with which the conversion script matches the database schema.
- Create a local directory somewhere on your hard drive, and unpack the contents of the WordPress 1.5.2 archive in there. Rename the
wordpress/directory towp152/so we can tell it apart from other versions. Enter thewp152/directory now. - Make a copy of the file named
wp-config-sample.phpto another file calledwp-config.phpthen edit it with a text editor. You are going to need to change the first three definition lines to match your pMachine database name, and a user and password that has access to that database. Important Note: Because of the limitations of this script, you must install WordPress to the same database as pMachine is installed to. I sympathise if that seems like a poor design decision; I didn’t program the plugin and would have done things differently if I had. - Place a copy of the pMachine import plugin you downloaded above into the
wp-admin/directory. Remember to rename the file toimport-pmachine23-03.phpif you haven’t already! - Load the file
import-pmachine23-03.phpinto a text editor and configure it to access your pMachine database tables (using the same database name, username nad password as in step 2 above). You may also need to alter thePM_PREFIXoption if you didn’t install pMachine with the defaultpm_prefix on all database tables. Save your changes when done editing the file. - Send the
wp152/directory and its contents to the root of your web server (e.g./home/username/public_html/wp152/...). If your host lets you decompress files remotely (e.g. via a control panel tool), you can save some time by compressing the directory, uploading it, then decompressing it on the web server. If not, or you don’t know how, that’s fine too—it will just take a little longer to transfer. - Once everything is uploaded, you need to initialize your WordPress installation’s database. In a web browser, call up the directory containing your WordPress 1.5.2 files. This will be something like http://www.mydomainname.com/wp152/. You should see a message on the screen that reads:
It doesn’t look like you’ve installed WP yet. Try running install.php.
Click the link to begin installing WordPress. The instructions are very easy to follow. When you get to the second step, be sure to make a copy of the password. Click the wp-login.php link and sign in using the provided credentials. You can now click the Users tab and change the administrator password to something easier to remember, if you want.
- Now we’re going to delete the sample content. Go to the Manage tab and delete the “Hello World!” post. Next, go to the Links tab and delete all the links shown. You should now have a “clean slate” with which to import your pMachine blog content.
Conversion
- You should now be ready to convert your pMachine entries to WordPress. At this point you definitely want to make sure you have fresh backups of everything—It’s your own fault if you lose any data by proceeding beyond this point; you’ve been warned several times now.
- You will need to be signed into WordPress as the administrator. If you aren’t already signed in, do that now.
- Access the following page on your website, replacing it with your domain name: http://www.yourdomainname.com/wp152/wp-admin/import-pmachine23-03.php
- If the import failed, you’ll have to review the error messages. One common problem is the appearance of single quote-marks in content that haven’t been properly escaped. The easiest thing to do there is track down the “offending” record in PHPMyAdmin and remove the quotemark entirely (you can always add it back in later). If you are seeing an enormous list of errors, something more serious has gone wrong, and your WordPress database may be toast. In any event, before trying anything else, access PHPMyAdmin and drop all database tables beginning with
wp_from your database, then go back to Installation step 6. Before trying to run the import script again, you should obviously correct the problem. - Now that you’ve upgraded, you’ll probably discover your WordPress installation appears busted if you try to access it via your browser. Go into PHPMyAdmin and open the table named wp_options, then browse the column contents. The most likely edit you’ll need to make immediately is the value for the record with option_name = ’siteurl’, which will be set to the location of your pMachine blog—but you’re in a different subdirectory now, so you’ll need to change this value. Click the Edit icon on the correct column and change the value to the directory you installed WordPress to: http://www.mydomainname.com/wp152/.
- The home page should now render correctly, and your content should be showing up. Before proceeding any further, though, we’re going to make sure the correct permissions are assigned to your imported users (most importantly, your old administrator account from your pMachine installation). Go to the administration interface, then click on the Users tab, followed by the Authors & Users sub-tab. Click Promote beside your old account name, then adjust the user level to as high as it will go (level 9). You can worry about everyone else’s levels after upgrading to WordPress 2.x.
- Now might be a good time to make another backup of your current database, so that if anything else goes wrong you can restore to this point.
, which will start the conversion process. Access this file only once, or you’ll be starting over from several steps back. Unlike most of WordPress, the process is pretty ugly and not very user-friendly. If it completed successfully, you will see something that looks like this:
# Importing preferences… oops while converting posts_per_pageoops while converting comments_notify# OK # Importing members… # OK # Importing categories… # OK # Importing posts… # OK # Importing comments… # OK # Importing trackbacks…
Warning: Invalid argument supplied for foreach() in /home/username/htdocs/wp152/wp-admin/import-pmachine23-03.php on line 336
# OK # Importing pingbacks…Warning: Invalid argument supplied for foreach() in /home/username/htdocs/wp152/wp-admin/import-pmachine23-03.php on line 364
# OK
Note that there are a few “oops” statements, which means some preference data didn’t get converted—and a couple warnings were displayed on lines 336 and 364 (which relate to Trackbacks and Pingbacks, specifically, neither of which this blog had any of)—but ultimately the import has succeeded. If the import appears to have succeeded, delete the /wp152/wp-admin/import-pmachine23-03.php file from the web server now. You don’t want to run it again by accident.
Upgrade to WordPress 2.x
- Now you can upgrade to WordPress 2.x. Extract the files into the root web directory on your local server, copy the
wp152/config.phpfile over, then upload everything to your root web server. - Access PHPMyAdmin again and change the option_name = ’siteurl’ setting to just the domain name (without the wp152/ bit on the end).
- Now call up http://www.mydomainname.com/wp-admin/ in your web browser. It will immediately warn you that …
Your database is out-of-date. Please upgrade.
Click the link and follow the instructions. This is even easier than installing WordPress!
- You should now be signed into the administration interface. Your content is now converted, and your installation up-to-date!
The Clean-Up
You’re just about done—but there are a few things missing that you should know about before calling it a day.
- Private Entries: Well, they aren’t private anymore. Unfortunately, WordPress doesn’t have a mechanism for making entries private by default. You can easily add this functionality with a WordPress plugin named Post Levels. All the work isn’t done for you, however: You’ll still need to manually decide which posts to make private, and you’ll need to edit your users’ Users > User Levels to match those you assign to your posts.
I can lead you water, but you’ll have to drink for yourself. To get a list of all the posts you had set to be private in pMachine, access PHPMySQL, then click the table named pm_weblog. Now click the SQL tab and enter the following text:
SELECT post_id, title, body, custom1 FROM `pm_weblog` WHERE custom1 REGEXP 'private' LIMIT 99
… Then click Go. This will produce a list of all the posts you had marked as private in pMachine.
Now, you will want to know how WordPress tracks post privacy; it does so in a table named wp_postmeta. Entries in this table are simple, with four values:
- meta_id: A unique identity for each row in the table
- post_id: The post ID to which you want to apply a meta-setting
- meta_key: The name of the setting you are applying to the post
- meta_value: The value of the key being set
So, if you were to add a new record as follows:
INSERT INTO `wp_postmeta` (`post_id`, `meta_key`, `meta_value`) VALUES ('513', 'post_level', '4');… That would make WordPress post number 513 viewable only by users assigned User Level of 4 or higher. Of course, you should take a moment to verify that pMachine’s post IDs match up to WordPress’s before you go any further. You did remember to delete the “Hello World!” post before importing, right?
How to perform a bulk update should now be pretty obvious: Use the first query to get a list of all the entries you had marked as being private, then use the second query to plug these into WordPress in a way that it understands. You can insert multiple values by providing a comma-separated list of tuple values, e.g.:
INSERT INTO `wp_postmeta` (`post_id`, `meta_key`, `meta_value`) VALUES ('2', 'post_level', '4'), ('5', 'post_level', '4'), ('27', 'post_level', '10'), (... etc. ...);Now the mapped posts should be private. Unlike pMachine, private posts in WordPress are completely invisible to users who have insufficient access to read them—This means they’ll be completely invisible to you when you’re signed out, so testing to make sure your entries are now private should be pretty straightforward.
- Static Pages: Any static (e.g. not blog entries) pages you have created will not be converted. You will have to do this manually. WordPress makes adding static content easy, though: click Write > Write Page to create a new static content page. You can just copy and paste your existing HTML, name and slug the page, then save.
- Blogroll: Your existing blogroll won’t have been converted; you’ll have to do this yourself as well, although it should be pretty quick (unless you have hundreds of blogroll entries—isn’t it about time you cleaned the cobwebs from your blogroll anyway?). You will also notice that any fancier “webrings” etc. you are a member of can’t be input directly into the Blogroll tool; as a substitute, I recommend putting these things into a separate PHP file and including them into the sidebar, or use a pre-built HTML widget via a plugin.
- Design/Layout: Sorry, but there aren’t two blogging systems on Earth that use the same mechanism for designing how a page looks, or where everything appears. You’ll have to design something new, or port your design to work with WordPress. If I may make a suggestion, consider using K2—it may be a bit less flexible than designing your own from scratch, but its sophisticated features make it worth using (AJAX tools, sidebar management) and means less fiddling around with plugins and layouts before you get your blog to a point where you’re happy with it.
- Spam Handling: Your spam blacklisted words weren’t imported, nor were comments that weren’t approved (although you probably won’t miss them). You can edit the Spam settings and import your blacklisted words if you want, but I have a (much) better suggestion for you: A plugin called Akismet, which will make your life much, much easier. You’ll need to read that page and follow the instructions to get it up and running, but don’t worry—installation is quick and the result is damned effective. How good is it? Since installing it, my blog has received 2,227 comments, 2,225 of which were SPAM. Akismet missed one of them. If those numbers seem freaky to you, there is one easy way of reducing comment SPAM significantly: disable trackbacks. Another measure is to prevent anonymous users from leaving comments, although this could adversely impact people wanting to leave legitimate comments. It’s up to you.
- Closed Messages: Any messages you had marked as being “Closed” (e.g. not viewable by anyone at all, except you, via the pMachine admin interface) have been converted to the equivalent WordPress status, Draft. You can see your draft posts at the top of the Write and Manage pages. If your drafts aren’t relevant/required anymore, just delete them.
- Text Editor: By default, WordPress will probably stick you with the HTML post editor. While it’s actually not half bad (and is more capable than the GUI editor because its capabilities aren’t limited by the buttons it provides), you may prefer to edit your posts in a visual manner. Don’t worry, you can have the best of both worlds: Click Users > Your Profile and check the box marked Use the visual editor when writing. Now you will see two tabs when writing content: Visual, which is the visual rich-text editor (which works similar to Windows WordPad), and Code, which lets you edit HTML directly.
- Backups: You don’t have to use PHPMyAdmin every time you want to make a backup of your WordPress database—Just install the WordPress DB Backup plugin and you’re off to the races. Save early, safe often, as they say; Now there’s no excuse not to.
That’s it. I don’t know if I can be of much help for anything I haven’t already covered, but if you do run into problems you can try dropping me a line, or asking for help on the WordPress Forums. Good luck!
Kevin,
this looks very interesting to me - my blog is however a very images-based blog. What happens to all the posts with images? I guess they should still be located in the same folder on the server, but will they be included?
Best regards,
Peter
Hi Peter!
I’m glad you asked; I should have pointed out that images (and other dependencies, such as relative links) can create additional challenges; but nothing you can’t handle, I’m sure.
In a nutshell, there are essentially three ways you can have included images in your posts:
src="images/pic.jpg"orsrc="../images/pic.jpg"src="/images/pic.jpg", orsrc="http://www.mysite.com/images/pic.jpgThe good news is that in all three cases, you should have little to no problem keeping the images linked correctly if you keep the images folder in the same location as it is now on your existing pMachine blog on your new WordPress blog.
In the worst-case scenario, if you need to alter the links, you can actually do so “in bulk”—Just use a text editor on a .sql file to make the change as required before importing it to the new database. There are obviously other ways of doing this too, but they involve writing SQL queries which is a bit more involved and potentially complicated than just using a text editor.
Hopefully that answers your question! If you’re still curious/cautious about how it will work out, remember the following:
That way, no matter what happens, if something goes horribly wrong you’ll be able to recover from the mistake quickly. As for the pMachine and Wordpress blogs, though, both can nearly co-exist completely with the exception of a couple filenames (i.e. index.php)—so recovering from a disaster will actually be quick and painless.
Good luck, and let me know if you have any other questions or need help!
I followed your guide and it worked perfectly. I’ve been dreading the move for over two years. I wish I’d thought to search for some help a long time ago.
Now I’ve just got to figure out the new tag system!
Thanks again.
Glad to hear it worked for you, Jenny! Thanks for dropping me a note to say so.
Question regarding PMachine categories. I suspect it won’t import the category designation for each entry? If so, what if I duplicated the categories in WordPress 1.52 before importing in the PMachine database — would the posts import into their consecutive categories then? Have you tried this? I’ve got close to 6,000 posts in my PMachine Pro 2.3 site. This page is very helpful and I shall follow it during my conversion to WordPress. I like Expression Engine, but it seems the most popular is WordPress and there are so many templates available for it I’ve seen that are cool.