HomeNews and blogs hub

Migrating SourceForge Wordpress blog from "hosted apps" walkthrough

Bookmark this page Bookmarked

Migrating SourceForge Wordpress blog from "hosted apps" walkthrough

Author(s)

Mike Jackson

Posted on 20 June 2012

Estimated read time: 12 min
Sections in this article
Share on blog/article:
Twitter LinkedIn

Migrating SourceForge Wordpress blog from "hosted apps" walkthrough

Posted by m.jackson on 20 June 2012 - 2:56pm

TypewriterCloseUp.jpgBy Mike Jackson.

SourceForge announced yesterday that they will be retiring their "hosted apps" from 1st September. This includes Wordpress blogs which they have already disabled. The OGSA-DAI project, which I was involved with for many years, used these blogs, as did the OGSA-DAI Workbench project. So, I followed SourceForge's guide on Migrating Wordpress from Hosted Apps to Project Web, and in this post I describe my experiences as to how it went in practice, using their headings and text where appropriate. I hope you find this a useful complement to SourceForge's own guide.

 

In what follows, replace ogsa-dai with your project name and sfuser with your SourceForge username.

1) Get backup of your Wordpress database

The database contains all blog pages, user accounts and other configuration

Log in to SourceForge

Go to project home page e.g. http://sourceforge.net/projects/ogsa-dai

Select Project Admin => Features

Feature Settings page appears with Enabled Features table

In Backups row, click Hosted Apps

SourceForge.net Project Hosted Application Backup Tool appears

  • Select Content to backup: Database
  • Select Content format: plain
  • Select Application to backup: wordpress

Click Submit Query

Dialog will pop up allowing you to save ogsa-dai_wordpress_mysqldump.sql

2) Enable MySQL for your project

Go to project home page e.g. http://sourceforge.net/projects/ogsa-dai

Select Project Admin => Features

Feature Settings page appears with Enabled Features table

In Project Database (MySQL) row, click Manage

MySQL Service page appears. This shows information including

  • Host name e.g. mysql-o
  • Database name prefix e.g. o261620_
  • Database users e.g. o261620ro, o261620rw, o261620admin

In what follows, replace the above with your own host name, name prefix or users

Enter passwords for the three MySQL user accounts, if you have not already done so

Click Set passwords

A green message will appear, "Password data recorded. Changed passwords will be available on the MySQL server in approximately five minutes."

3) Load the database dump

Secure copy the database dump to your SourceForge account

$ scp ogsa-dai_wordpress_mysqldump.sql sfuser@web.sourceforge.net: sfuser@web.sourceforge.net's password: ogsa-dai_wordpress_m 100% |*****************************| 2610 KB 00:01

Log into the SourceForge secure shell

$ ssh -t sfuser,ogsa-dai@shell.sourceforge.net create sfuser,ogsa-dai@shell.sourceforge.net's password: Requesting a new shell for "sfuser" and waiting for it to start. queued... creating... starting... This is an interactive shell created for user sfuser,ogsa-dai. Use the "timeleft" command to see how much time remains before shutdown. Use the "shutdown" command to destroy the shell before the time limit. For path information and login help, type "sf-help". $

Create a database for Wordpress

Remember to replace mysql-o, o261620admin, o261620_ with your database prefix, database administrator user and database prefix as described in step 2

$ mysqladmin -h mysql-o -u o261620admin -p create o261620_wp Enter password:

Load the database dump

$ mysql -h mysql-o -u o261620admin -p o261620_wp < ~/ogsa-dai_wordpress_mysqldump.sql Enter password:

Clean up

$ rm ogsa-dai_wordpress_mysqldump.sql

4) Download and install a fresh copy of Wordpress from wordpress.org

Change into your project's web directory

$ cd /home/project-web/ogsa-dai/htdocs

Download Wordpress (the current version was 3.4 at time of writing)

$ wget http://wordpress.org/latest.zip ... 2012-06-20 12:19:39 (10.3 MB/s) - `latest.zip' saved [4920516]

Unzip and rename the directory, so the blog URL includes "blog"

$ unzip latest.zip ... $ mv wordpress/ blog/

Set permissions for directory that will hold uploaded files (I had to do this otherwise uploading images failed)

$ chmod g+w blog/wp-content/

Clean up

$ rm latest.zip

5) Fix some of the Wordpress data

This corrects hard-coded values in the database

Log into the database

$ mysql -h mysql-o -u o261620admin -p o261620_wp Enter password: ... mysql>

The OGSA-DAI web space on SourceForge is located in /home/project-web/ogsa-dai/htdocs/

And I want my blog to be in a blog/ subdirectory

So my upload path is /home/project-web/ogsa-dai/htdocs/blog/wp-content/uploads and my blog URL will be http://ogsa-dai.sourceforge.net/blog/

And my UPDATEs are

mysql> UPDATE wp_options set option_value = '/home/project-web/ogsa-dai/htdocs/blog/wp-content/uploads' where option_name = 'upload_path'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> UPDATE wp_options set option_value = 'http://ogsa-dai.sourceforge.net/blog/' where option_name = 'http_authentication_logout_uri'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> UPDATE wp_options set option_value = 'http://ogsa-dai.sourceforge.net/blog/' where option_name = 'siteurl'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> UPDATE wp_options set option_value = 'http://ogsa-dai.sourceforge.net/blog/' where option_name ='home'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0

(In the SourceForge migration guide the first UPDATE is listed as: 

UPDATE wp_options set option_value = '/home/users/u/us/username/projectweb/projectname/htdocs/blog/wp-content' where option_name = 'upload_path';

but there was no such path, I was not hosting the blog in my home directory, and having wp-content/, instead of wp-content/uploads meant that I could not view any uploaded images)

7) Point Wordpress at your database

Copy the sample configuration file to the standard configuration file location

$ cd blog $ cp wp-config-sample.php wp-config.php

Edit wp-config.php and update the various DB_* fields to reflect the database configuration

$ emacs wp-config.php define('DB_NAME', 'o261620_wp'); define('DB_USER', 'o261620rw'); define('DB_PASSWORD', 'PASSWORD'); define('DB_HOST', 'mysql-o');

Now, to set up secret keys as this is recommended in the Wordpress documentation so browse to https://api.wordpress.org/secret-key/1.1/salt/

This gives a page like:

define('AUTH_KEY', 'long random string'); define('SECURE_AUTH_KEY', 'long random string'); define('LOGGED_IN_KEY', 'long random string'); define('NONCE_KEY', 'long random string'); define('AUTH_SALT', 'long random string'); define('SECURE_AUTH_SALT', 'long random string'); define('LOGGED_IN_SALT', 'long random string'); define('NONCE_SALT', 'long random string');

Copy these into wp-config.php, replacing the lines,

define('AUTH_KEY', 'put your unique phrase here'); define('SECURE_AUTH_KEY', 'put your unique phrase here'); define('LOGGED_IN_KEY', 'put your unique phrase here'); define('NONCE_KEY', 'put your unique phrase here'); define('AUTH_SALT', 'put your unique phrase here'); define('SECURE_AUTH_SALT', 'put your unique phrase here'); define('LOGGED_IN_SALT', 'put your unique phrase here'); define('NONCE_SALT', 'put your unique phrase here');

For more information on Wordpress installation see,

7) Run Wordpress upgrade

I'd forgotten my Wordpress username/password so created one via MySQL (thanks to a tutorial on how to add an admin user) as follows

Change wpadmin in the MD5 value to something more secure and likewise change the e-mail

mysql> INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('wpadmin', MD5('wpadmin'), 'Wordpress Admin', 'user@somewhere.ac.uk', 'http://', '2011-06-07 00:00:00', '', '0', 'Wordpress Admin'); Query OK, 1 row affected (0.00 sec)

Now get the ID of this user

mysql> SELECT ID FROM wp_users WHERE user_login = 'wpadmin'; +----+ | ID | +----+ | 34 | +----+ 1 row in set (0.00 sec)

Now, replace "34" with the ID returned above in the following

mysql> INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '34', 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '34', 'wp_user_level', '10'); Query OK, 1 row affected (0.00 sec) mysql> exit

Visit the login page e.g. http://ogsa-dai.sourceforge.net/blog/wp-login.php

(In the SourceForge migration guide it states

Go to the URL http://projectname.sourceforge.net/blog/wp-admin and log in

But for http://ogsa-dai.sourceforge.net/blog/wp-admin/install.php this gave me a "No Update Required" page and a Continue button which I clicked. This took me to http://ogsa-dai.sourceforge.net/blog which was a blank page.)

If you see a page "Database Update Required" then click Update WordPress Database

If you see a page "Update Complete" then click Continue

If it begins to cycle back and forth between these two pages then completely clear your browser cache and explicitly visit the login page e.g. http://ogsa-dai.sourceforge.net/blog/wp-login.php

8) Choose a valid theme

Select Appearance => Themes

Click Activate under Twenty Eleven

You may get a warning "The active theme is broken. Reverting to the default theme." and this may be selected automatically

9) Fix missing plugins

Click Plugins

You may see errors like

  • The plugin disable-wordpress-core-update/disable-core-update.php has been deactivated due to an error: Plugin file does not exist.
  • The plugin disable-wordpress-plugin-updates/disable-plugin-updates.php has been deactivated due to an error: Plugin file does not exist.
  • The plugin http-authentication.php has been deactivated due to an error: Plugin file does not exist.

This is expected, as you haven't installed those plugins, and some of them are SourceForge-specific plugins

10) Update .htaccess file

Select Settings => Permalinks

Click Save Changes

If your directory is writeable, this will update your .htaccess file

If it's not, this will tell you what you need to put in your .htaccess file. Use CTRL+A to select the text at the bottom of the page under the Save Changes button

$ emacs .htaccess

Paste

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule>

In either case, make sure that the .htaccess file isn't writable once you're done

$ chmod -w .htaccess

11) You should be done with the data part now

Browse to front page

http://ogsa-dai.sourceforge.net/blog/

12) Download a backup of any uploaded files

The files are all the images and attachments used in the blog

Go to project home page e.g. http://sourceforge.net/projects/ogsa-dai

Select Project Admin => Features

Feature Settings page appears with Enabled Features table

In Backups row, click Hosted Apps

SourceForge.net Project Hosted Application Backup Tool appears

  • Select Content to backup: Database
  • Select Content format: plain
  • Select Application to backup: wordpress

Click Submit Query

Like other users, I found that this currently does not work...I've raised a ticket on SourceForge (#26284). When this is resolved I'll update in due course

13) Copy this file up to your SF account

This is untried. When the above is resolved I'll do it and update this post!

$ scp ogsa-dai_wordpress_files.tar.gz sfuser@web.sourceforge.net:

 13) Unpack this file 

This is untried. When the above is resolved I'll do it and update this post!

$ tar -vzxf projectname_wordpress_files.tar.gz

This will unpack into a directory called projectname

Move all of the contents of that directory into the wp-content directory of your new Wordpress installation

14) OK, now you're really done

Apart from...

What about broken links?

In the OGSA-DAI blog we had a number of from one article to another. These were absolute links prefixed with e.g. http://sourceforge.net/apps/wordpress/ogsa-dai/. An easy way to update these to the new blog URL prefix e.g. http://ogsa-dai.sourceforge.net/blog is to:

Dump your database

$ mysqldump -h mysql-o -u o261620admin -p o261620_wp > ogsa-dai-wordpress.sql

Load the database dump into an editor

$ emacs ogsa-dai-wordpress.sql

Do a search for all the old link prefixes and replace these with the new link prefixes

Upload the database dump back into the database

$ mysql -h mysql-o -u o261620admin -p o261620_wp < ~/ogsa-dai_wordpress_mysqldump.sql

Outstanding issues

 These are the outstanding issues I have,

  • New users should be able to register and receive an automated reply by e-mail. No e-mails are being sent
  • Need to check what the file space quota is

How to back up your blog

You can back up your blog as follows

Log in via secure shell

$ ssh -t sfuser,ogsa-dai@shell.sourceforge.net create

Change into your project's web directory

$ cd /home/project-web/ogsa-dai/htdocs

Dump the database

$ mysqldump -h mysql-o -u o261620admin -p o261620_wp > ogsa-dai-wordpress.sql

Secure copy it to wherever you want to back it up to

Likewise secure copy blog/wp-content to back up all your files

Online MySQL browser

You can also interact with your SourceForge MySQL database via the URL specified in step 2 e.g. https://mysql-o.sourceforge.net

Problems?

Feel free to comment on this post, point out any alternatives or additional information

Please direct any support requests or problems direct to SourceForge support

Share on blog/article:
Twitter LinkedIn