Always Get Better

Posts Tagged ‘wordpress’

How to Move a Wordpress Database

Saturday, April 4th, 2009

One of the most common requirements for web developers is the ability to switch code from development servers to live production environments. This can be tricky if you’re working with Wordpress; moving the files is dead simple, but since Wordpress uses canonical URLs you have to be careful if you are trying to transfer any of your database content.

Canonical URLs force your site to use the same base path (www.yourdomain.com rather than yourdomain.com). But if you are working in a development environment – e.g. the development site’s address isn’t the same as your web site, but is rather something like 127.0.0.1 – you need to be able to make the switch to Wordpress without bringing your site down.

Since I end up having to look for this information so often, here are the steps I use to accomplish this amazing feat:

Download The Database

From the shell prompt of your server, dump Wordpress’ MySQL database into a backup file:

mysqldump –-add-drop-table -uusername -ppassword databasename > mysqlbackup.DATE.sql

Move it over to the new server and run this command to overwrite your target:

mysql -udb##### -p -hinternal-db.s#####.gridserver.com db#####_dbname < mysqlbackup.DATE.sql

Update the Database Paths

Log into your MySQL database and issue this update command to ensure Wordpress redirects to the new server:

UPDATE wp_options SET option_value = replace(option_value, ‘http://www.old-domain.com’, ‘http://www.new-domain.com’) WHERE option_name = ‘home’ OR option_name = ’siteurl’;

Next update the post URLs:

UPDATE wp_posts SET guid = replace(guid, ‘http://www.old-domain.com’,'http://www.new-domain.com’);

Finally, update your posts’ content to fix any internal links:

UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.old-domain.com’, ‘http://www.new-domain.com’);

That’s all! Repeat these steps when moving from production to development and vise-versa.

As I said I typically search for this information whenever I need to move Wordpress sites. I find the SQL queries at: http://www.mydigitallife.info/2007/10/01/how-to-move-wordpress-blog-to-new-domain-or-location/

  • Share/Bookmark

Post-Dating Blog Entries in Wordpress (or, the Absent-Minded Blogger)

Sunday, December 7th, 2008

Wordpress is a great tool; I am looking forward to version 2.7 although I find myself hard-pressed to try to imagine how the WP team is going to improve upon the existing platform. One of my favourite functions of the Wordpress software is the ability to post-date entries. Often I will get a burst of inspiration and write four or five articles.  Rather than releasing them all at once I will set them to automatically publish into the future so there is a steady stream of content always appearing on my home page.

Most cream-of-the-crop blogs add 2-3 new entries daily. Always Get Better is certainly not in that category, however I try to post at least once per day. As I am busy with other work and blogs, I don’t necessarily have the time to write a decent article every day (although I do often make the time). Since the content here is not particularly topical, it doesn’t matter too much if it doesn’t go up hot off the press. In fact, by pre-publishing my articles I have a decent opportunity to go back and review what I’ve written which improves the overal quality of my writing.

Some blogs exclusively post content written long ago. I certainly don’t advocate going to that extreme though since a blog that is totally on autopilot risks losing some human connection. As long as the authors review, post and respond to comments in real time I suppose it wouldn’t matter in the long run.

  • Share/Bookmark

Improving Wordpress Page Titles

Saturday, November 29th, 2008

Anyone half-serious about running a large blog knows that search engine ranking is critical to getting properly indexed. Over 90% of the traffic to Always Get Better originates from search engine traffic – therefore the ease of which Google (among others) is able to index this site is the life-blood of its continued success.

Wordpress is a terrific platform with out-of-the-box support for many of the critical elements necessary for site building: CSS layouts, RSS feeds, track backs. But the glaring problem with Wordpress is the default title format: “Blog Name > Blog Archive – Post Title”. What is that!?

Many search engines only catalogue the first several characters of web page titles. If the title of your post is at the end of the page title, it may get cut off in favour of your blog’s name!

The simple solution is to reverse the code as explained at the Wordpress garage (and quoted below for convenience):

You can switch it through the use of plugins, but if you want to avoid using another plugin you can fix this in the header.php file. Find the code that starts with <title>, and replace what is currently there with this:

<title><?php if ( is_single() ) { ?> <?php wp_title(''); ?> &raquo; <?php } ?><?php bloginfo('name'); ?></title>

  • Share/Bookmark

Apache: Enabling mod_rewrite on Windows 2003 Server

Monday, April 21st, 2008

Recently I had to set up a Wordpress blog on a Windows 2003 server, which involved installing Apache, PHP and MySQL.  Everything went pretty well – except for the typical PHP.ini problems I shall write about later.

Once the database was set up and I had the blog running, I tried to adjust the permalink structure using .htaccess rewrite rules so they would be more human-readable.

Out of the box, mod_rewrite isn’t enabled on Windows Apache.

The steps I took to resolve the problem were:

  1. Uncomment the line containing ‘LoadModule mod_rewrite modules/mod_rewrite.so
  2. In the VirtualHost directive hosting the blog, add ‘AllowOveride All
  3. Restart Apache

It works like a charm, now.  All the tools ship with Apache, it’s just a matter of configuring them as needed.

  • Share/Bookmark

SEO Powered by Platinum SEO from Techblissonline