Koozali.org: home of the SME Server

Moving Wordpress

Offline EdelingF

  • *****
  • 215
  • +0/-0
Moving Wordpress
« on: January 17, 2012, 07:39:07 PM »
Since I'm (finally) moving my websites from my old (P1, 1Ghz, SME7) server to a new server, I'm currently setting up this new server (SME8b7 as VM in VirtualBox on SME8b7).
My websites run on Wordpress in opt, so moving them should be easy (http://codex.wordpress.org/Moving_WordPress). The strange thing that happens is that half of my websites don't work after moving them.
Three of them work like they have never been moved, but the other ones give the following errors:
- You don't have permission to access /cms/wp-admin on this server.
- The requested URL /site/wp-admin was not found on this server.
They all are copyed the same way, wp-config.php looks ok, databases are ok, permissions look ok, templates are ok.
I can't figure out what I'm doing wrong. Has anyone got an idea where to look?
...

Offline mmccarn

  • *
  • 2,651
  • +10/-0
Re: Moving Wordpress
« Reply #1 on: January 18, 2012, 02:19:26 PM »
Moving wordpress becomes tricky if the absolute URL of the root of the installation changes.

You might be able to get the reluctant sites working again by adding the following lines at the bottom of <ROOT>/wp-config.php for each site:
Code: [Select]
define('RELOCATE',true);
define('WP_HOME','http://path.to/newurl');
define('WP_SITEURL','http://path.to/newurl');

However, I had trouble the *second* time I moved the same wordpress site using the wp-config.php method shown above, and decided I needed to update the paths inside the database.

Since the paths are stored in the database as "serialized strings" (a string value follwed by the length of the string), I had a hard time finding a tool that would rename the strings but keep the site working properly.  If I ran a mysql update to change the paths within blog posts, the length parameter also needed to be updated.

Eventually I found (and now use) David Coveney's 'F&R Database' script when moving Wordpress from place to place (to make a backup site for experimentation, for example): http://ringzer0devel.wordpress.com/2011/03/11/find-and-replace-in-mysql-database/

His post is a bit cryptic; here's how I ended up using it:

Code: [Select]
md ~/scripts
cd ~/scripts
<copy and paste the code from the above blog post into 'db-fr.php'>
<open the resulting file and clean up the duplicate code block in lines 124-132>
md include
cd include
<copy and paste the code from http://ringzer0devel.wordpress.com/2011/03/10/too-good-for-bash-love-php-read-on/ into 'commandline.class.php'>

Once setup, you can do global search/replace on your wordpress databases using:
Code: [Select]
OLDURL=some.path
NEWURL=path.to/newurl
DBNAME=somedb
DBUSER=someuser
DBPASS=somepasswd
/root/scripts/db-fr.php --find="$OLDURL" --replace-with="$NEWURL" --db-name="$DBNAME" --db-user="$DBUSER" --db-pass="$DBPASS" --verbose


Finally, make sure that the contents of <ROOT>/.htaccess make sense (don't include anything specific to the old blog location).

I have a script I've written to clone a wordpress installation into an i-bay (for backup purposes, mostly) - if that sounds useful I'll post it somewhere for you.
« Last Edit: January 18, 2012, 02:20:57 PM by mmccarn »

Offline EdelingF

  • *****
  • 215
  • +0/-0
Re: Moving Wordpress
« Reply #2 on: January 19, 2012, 07:44:16 AM »
I'll dive into that tonight, but the strangest thing is the location didn't change.

I copied all to the new server and renamed the new server to the old server and gave the new server the IP-adres of the old server. I allready thought about mysql, but since the IP-adres and server name didn't change I couldn't find anything.
Technically only the hardware and SME-version changed.

Besides one WP which I installed using the contrib, all of my WP's are installed by using SiteMaker (http://wiki.contribs.org/SME_Site_Maker) and I use mostly the same plugins. The themes are different, but I can't imagine that would give the output I got.
...

Offline EdelingF

  • *****
  • 215
  • +0/-0
Re: Moving Wordpress
« Reply #3 on: January 24, 2012, 07:16:28 PM »
I started all over again, step by step. I first copied all the WP-maps to the new server and then imported the databases in MySQL. Still one WP-website didn't work.
So I removed the maps of this website from opt and did a new install with SMESM. Same DB and same version WP as the old one. Then I copied the old WP-maps one by one into the new one. That did it, at last.

And now the rest of my data....
...

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: Moving Wordpress
« Reply #4 on: January 24, 2012, 11:05:08 PM »
EdelingF

With any SME backup/restore process it's a standard requirement to reinstall the contrib(s).

Quote
And now the rest of my data....

In theory that data and the wordpress sites, would have been transferred in a standard backup/restore, as long as you had enabled /opt to be included in the backup.
You could have done it all using the built in backup to workstation/USB.
« Last Edit: January 24, 2012, 11:08:25 PM by mary »
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline EdelingF

  • *****
  • 215
  • +0/-0
Re: Moving Wordpress
« Reply #5 on: January 24, 2012, 11:28:29 PM »
That was the plan and that was what I tried at first.
The problem was I couldn't make my virtual server connect to my USB HD. Then I tried backing up to an Ibay on my host server (on which VirtualBox is running). That worked, but I couldn't get my websites online.
So, yes you're right, that should have been the way. But now I'm learning a lot more about SME8 with which I hope to be able to help a lot of people later on.
...

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: Moving Wordpress
« Reply #6 on: January 25, 2012, 12:30:10 AM »
EdelingF

There are other workaround backup/restore methods listed here, not recommended for normal use, but will work OK in situations that require a different approach.
http://wiki.contribs.org/Backup_server_config
eg this using ssh
http://wiki.contribs.org/Backup_server_config#Command_line_manual_Restore_from_USB_drive_or_memory_stick
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.