NQB2 on the move! (Or "How to move a b2evo blog")
So you may notice that I've moved NQB2 to a new web host (hint: take a look at the new URL... http://josephhall.org/nqb2/).
You should update your feeds (see the list in the panel at right). It was a pretty clean move, if you notice any funny business, please send me an email.
For all of you b2evo bloggers out there who love a good how-to, I'll outline (in an extended entry below) the steps I took to make the move and do it cleanly.
[More:]
Moving a b2evolution blog from one host to another
-
First, you'll need a destination hosting provider... I chose Birdhouse Hosting run by Scot Hacker, the sysadmin of UC Berkeley's J-School. After paying the hosting $$$ and having your DNS record propogate... you should have something like my http://josephhall.org/ domain just waiting for data.
-
Then, you'll want to export your old blog's database tables. I used
phpMyAdminto do this. In phpMyAdmin, select the database that you want to export, then click on theExporttab. You'll want to export the whole database, so select the database in question. You will also want to select "Enclose export in a transaction" which will make importing the database and it's tables a snap. Have it save the export as a file with no compression. You should be prompted to download a.sqlfile which you should save locally. -
After that, you need to import the old database tables into a new database. Through your hosting provider, add a new database for your blog and a new user. Give that user access privileges for the new database. You should then zip or gzip the SQL file from the last step and upload it to the new domain (then uncompress it).
You'll need to manually edit the SQL file... look for the lines near the beginning that say:
CREATE DATABASE 'old_db'; USE old_db;
Where
old_dbis the name of the old database that you just exported. You'll want to comment out (with two minus signs,--) the first line here (we created the database in the last step) and then change theold_dbin the second line to the name of the database you created above:-- CREATE DATABASE 'old_db'; USE new_db;
Now, our SQL file is ready to be run. Type
mysql -u username -pat the command line (withusernamereplaced by the user you created for the blog database in the step above). Enter in the password for this user when prompted. You should now be at a mysql command line prompt. To run the SQL file, type:source localhost.sql;
Where
localhost.sqlis the name of your SQL file. This will take a little while but will copy all the contents of your old database's tables into new tables in the new database. -
Then, you need to copy over the blog's web and php pages to the new site. I recommend using
rsyncfor this purpose as it preserves permissions and such. For example, a command such as this should do the trick (run from the root directory (~/public_html/blog) of your old blog's location):rsync -avzue ssh --delete ./ username@newdomain.com:public_html/blog/
This will sync your new site with the old one and copy everything over, including symbolic links and preserving permissions.
-
Not done yet. You will have to modify various entries in
blog/conf/_config.phpon the new site (whereblogis the directory of your blog on the new domain). Make sure you change the following entries to reflect the new site:define( 'DB_USER', 'username' ); define( 'DB_PASSWORD', 'passwd' ); define( 'DB_NAME', 'new_db' ); define( 'DB_HOST', 'localhost' );
and also change the
$baseurlin the same file a few lines down to point to the new URL for your blog. -
Your new site should work now (call it up in a browser)... if you get an "Internal Server Error" it's likely because you have something like
AcceptPathInfo Onin your root.htaccessfile. If this is the case, rename the.htaccessfile to something likebak.htaccessand ask your hosting provider to enable this feature. -
Now we need to redirect users of the old site to the new site. You can look long and hard at the Apache documentation but there's only one thing you need to do... you'll need to have a one-line
.htaccessfile in the root directory of your old blog. The one line in this file should look like this:Redirect permanent /blog http://newdomain.com/blog
Where
blogis the directory of you old (and new) blog. This essentially redirects all requests for anything in your old blog to your new blog. -
Backup the old site and database and save somewhere. You should keep a copy of the SQL file that has your old exported database in it as well as a complete copy of your old blog (I'd use
rsyncto your local machine). -
When you've made backups, then delete the old site except the
.htaccessfile that is doing the redirecting. You can do arm -rf *in the root directory of your old blog but make sure you don't zap the.htaccessfile. -
Finally, poke around the new site and look for broken links (Note: anything that points to your old site is effectively "broken" as it will be redirected by Apache. You can also disable the redirect for a bit and see if everything holds up.)