Category Archives: InfiniteWP

Checklist for moving a PHP-based site from one server to another

Research

  • Make sure server configuration is the same. Install missing php extensions and modules. (A good way of comparing is by diffing the output of phpinfo() between the two servers.)
  • Check the mail configuration on the new server. (Is it Sendmail, Postfix or something else? Is any configuration required to get the mail() function working?)

Move

  • Move files (Best ways are either to pack them in an archive (.tar.gz) or moving the files via sshfs.
  • Set file permissions (files should typically be owned by the web server unless you run some sort of suexec config.)
  • Move databases and create database users on the new server.
  • Move CRON jobs (Crontab, etc)
  • Update DNS records (Don’t forget the MX records for mail, and any SPF records you may have.)

Application-specific: WordPress

  • Disable caching plugins (If you figure this out too late, just comment out define(‘WP_CACHE’, true); from wp-config.php and then Disable -> Enable -> Activate your caching plugin through wp-admin.

Post-move

  • Run CacheCheck to see if your DNS has propagated
  • Monitor site via Pingdom or similar service for errors after the move. (And not only timeout, make sure you check for non-200 HTTP code errors too!)

Anything missing? Post a comment!

InfiniteWP snippet library for Code Snippets Addon

InfiniteWP Logo

InfiniteWP Code Snippets Addon is a great tool to easily run code snippets on all your wordpress sites simultaneously.

Below you will find a couple of useful snippets for it. I’m going to add more snippets shortly. In the mean time feel free to post any good snippets you have in the comments!

Show blog title

echo get_bloginfo();    

Here is what that snippet looks in InfiniteWP. (More snippets after the image)

Code snippet example

Basic database interaction, getting the site URL

global $wpdb;
$table_name = $wpdb->prefix . "options";
$sql = "SELECT option_value FROM ".$table_name." WHERE option_name = 'siteurl';";
$root_url = $wpdb->get_var($sql);
echo $root_url;

This will return your site URL from the database.

Show server load averages

$loads = '';
foreach(sys_getloadavg() as $load)
{
    $loads .= $load . ', ';
}
echo substr($loads, 0, -2);

Show disk space (total/free) on your host

function decodeSize($bytes)
{
    $types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
    for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /= 1024, $i++ );
    return( round( $bytes, 2 ) . " " . $types[$i] );
}

function freeSpacePercentage($folder = ".")
{
    return round((decodeSize(disk_free_space("."))/decodeSize(disk_total_space("."))*100)) . "%";
}

function usedSpacePercentage($folder = ".")
{
    return round(((100*decodeSize(disk_free_space("."))/decodeSize(disk_total_space(".")))-100)*-1) . "%";
}

echo "Disk space: " . decodeSize(disk_free_space(".")) . " of " . decodeSize(disk_total_space("."));
echo " - ";
echo freeSpacePercentage() . ' free.';

Note 1: Some shared hosts have disabled the disk_total_space(). In those circumstances the snippet does not work.
Note 2: Free space is free space on the physical drive where WordPress is installed. On shared hosts this does not accurately represent your disk quota.