Author Archives: thowden

WordPress Multisite Error

A very open headline for what was a confusing WordPress Multisite Error. A more accurate headline after the event might be WordPress Multisite migration to a new server or domain url.

Scenario: An older wordpress site was migrated to a new server with PHP7.3 but was using PHP 5.6 on the old server and was not working on the new server. The problem was that the old server had been decommissioned.

At this point I was asked to review and fix if possible. I tried a number of processes just to see if an in-place fix was possible, including turning off the multi-site function for the site copy on the new server and processing wordpress updates, but turning the multisite back on failed to run the site.

So I created a ‘dev’ copy on a PHP5.6 enabled server, copied in the database, and the files, configured the options settings to change the live url to the dev url, and then stepped through the following:

First issue was that the url of https://dev.insertdomainnamehere.com/ would process but come up with a result of ‘server not found’ with the url modified to show as https://http//dev.insertdomainnamehere.com// which looked weird, was obviously broken, but why was it happening?

It seemed like a mod_rewrite issue, which pointed at the .htaccess setup so I reviewed that. Reference https://wordpress.org/support/article/multisite-network-administration/#htaccess-and-mod-rewrite
and compared all the lines, and the (potential) version matching issues, and I used the settings for 3.5+ which seems to still hold true for WordPress 5+. Nothing seemed wrong here.

Next I checked in the wp-config.php file and confirmed the database settings and then the various WordPress multisite parameters and in particular the define(‘DOMAIN_CURRENT_SITE’, ‘ https://dev.insertdomainnamehere.com/’) which I had modified from the live site url. I found that if I modified this setting then the broken url changed to correspond to this domain setting.

Why the weird url? Because this parameter should not include the protocol or the trailing slash. The correct format of this parameter would be:

define( 'CURRENT_DOMAIN_SITE', "dev.insertdomainnamehere.com"); 

So I turned off multisite setting with define(‘MULTISITE’, false) in the wp-config.php file and found that the access to the site was working, albeit without the Network option or subsites available. This just confirmed that the database connection was working and that the site configuration was ok, at least in part.

Checking the content of the database I noted that the subsites had table prefixes of wp_2_ and wp_3_ consistent with a multisite database, except there was no wp_1_ which made me wonder if the primary site was not configured correctly (strange as it had been working previously).

But that is correct. From one of the pages I reviewed ” It’s not supposed to make wp_1_* tables anymore. That was only done in WPMU and as of WordPress 3.0, you start with wp_* and all subsequent sites get numbers. ” So the wp_2 and wp_3 are correct.

Reviewing some more WordPress commentary searching for wp_1 gave up this reference at Stackoverflow on a WordPress database issue and while the problem was not the same, one of the replies slapped me as I had missed one of the multisite settings (or lack of it) in the wp-config.php.

define( 'WP_ALLOW_MULTISITE', true ); 

This is not the same as

define('MULTISITE', true);

and the wp-config.php file was missing the WP_ALLOW_MULTISITE parameter. (Why and for how long?) In any it was now added.

Not so much second, but just somewhere in the mix, I found that with some setting combinations, I would get a “Error establishing database connection” as a WordPress formatted error page. Which made me think that the database connection was wrong, but as mentioned above, swapping to multisite = false worked ok, so not database as such.

Next reference was found while I looked at Stackoverflow results again with https://stackoverflow.com/questions/19724781/wordpress-multisite-error-establishing-a-database-connection-in-localhost in which another comment not directly relevant to the issue was about checking the wp_blogs table.

Noting that I had modified all the wp_options tables to use the ‘dev’ site url, I checked the wp_blogs table only to find that these were (naturally) still pointing to the live site url’s. A quick modification to each of the primary and two subsite urls and the site was running smoothly.

In summary, for multi-site to work, we must have:

  • wp-config.php with both WP_ALLOW_MULTISITE and MULTISITE parameters defined as True.
  • update the wp_options tables AND the wp_blogs table to reference the new site url.
  • update or at least check in the wp_site_meta table for the ‘network admin’ access
  • correct format of the parameter for CURRENT_DOMAIN_SITE

Now, I should be able to get on with security patching and reinstatement as a live site.

Install Imagick for WordPress on CPanel WHM Server

A quick how-to Install Imagick for WordPress on CPanel WHM Server.

Running Site Health check within and updated wordpress site shows:

One or more recommended modules are missing

PHP modules perform most of the tasks on the server that make your site run. Any changes to these must be made by your server administrator.
The WordPress Hosting Team maintains a list of those modules, both recommended and required, in the team handbook (opens in a new tab).

Warning The optional module, imagick, is not installed, or has been disabled.

Following many of the search links to resolve this leads to using the Module Installer PECL via the WHM console, but for me I got this error:

WARNING: channel “pecl.php.net” has updated its protocols, use “pecl channel-update pecl.php.net” to update Warning: popen() has been disabled for security reasons in OS/Guess.php on line 241 Warning: fgets() expects parameter 1 to be resource, null given in OS/Guess.php on line 242 Warning: pclose() expects parameter 1 to be resource, null given in OS/Guess.php on line 251 downloading imagick-3.4.4.tgz … Starting to download imagick-3.4.4.tgz (253,434 bytes) ……………………………………………..done: 253,434 bytes 19 source files, building running: phpize Warning: popen() has been disabled for security reasons in PEAR/Builder.php on line 465 ERROR: failed to run `phpize’

Continuing my search ended up at the CPanel forums and a resolution for installing imagick from cPanelMichael and a command line option – noting that I modified my command line to use ea-php73 which is the target version of php for this WordPress site.

/opt/cpanel/ea-php70/root/usr/bin/pecl install imagick

Reviewing my own setup, I had already used the following script.

/scripts/installimagemagick”
before proceeding with the “imagick” PECL installation

Running the Site Health check again showed the same issue. So I restarted Apache and the PHP-FPM services and tested again. Issue resolved.

Bigpond Telstra Foxtel Cable Modem Outages

This is my blog of Bigpond Telstra Foxtel Cable Modem Outages.

It has become a constant and I need to document to support a claim.

Another 20 minute outage in Croydon Vic 3136 at 1345 to 1405 Thursday 1st Nov 2018.

Powered modem down and up, no change. Disconnected fully and reconnected, powered up again. Still no Internet green light at 1455. Started to configure my alternative notebook via iPhone to get connectivity and at 1405 Internet ‘magically’ appears.

That is not modem or cable fault. It is a technician changing stuff and power down / power up of kit at the exchange. I am certain of it and it has been happening ever since the NBN roll-out started in my area.

Time wasting.

How to change iTunes backup location Windows 10

My C: drive  (SSD) was short on space and one of the culprits is iTunes Backups. So this article is how to change iTunes backup location on Windows 10.

Obviously using an SSD for performance on a desktop is great, but not so great when you find that it is almost full. 

Using WinDirStat, a long time favourite utility, I confirmed that aside from the ever disk hungry Windows 10 install, the next highest consumer of my precious SSD disk space was iTunes Backups directory. 

So I could rid myself of some of the older iPhone and iPad backups on my drive, but I thought I would simply relocate it to my slower, but much larger D: drive where the capacity is not an issue. 

This article from CopyTrans was relating to Windows 7 and selling their products, but it gave me the pointers on what to do. 

The key points are:

  1. create a new location on the alternative drive, D: in my case
  2. copy your existing backups to the new location
  3. rename the old backup directory
  4. create a symbolic link to the new location from the old
  5. remove the old backup directory after testing

The main pain points were mklink not being recognised as a command and the need to use case sensitive path names.

Covering the process in detail:

  1. Create a new location on D:
    • I was already using a path copy from c: for my music copy and I just needed to create the  
    • d:\Users\thowden\AppData\Roaming\Apple Computer\MobileSync\Backup
  2. Copy existing backup files to the new directory – straight forward 
  3. Rename the old backups directory as backup-old just in case of accidents
  4. Create a symbolic link
  5. This is where it went pear-shaped as the mklink command in powershell gave me an error
    • mklink : The term ‘mklink’ is not recognized as the name of a cmdlet, function, script file, or operable program.
    • This is easily fixed by prefixing the mklink command with cmd /c
    • so the command syntax is:  
      cmd /c mklink /J <linked path> <target path> 
    • Which gave me a new symbolic link but an error when I tried to use it:
          “Location is not available”
    • Which I confirmed was an issue with the command because I used all lower case characters and not the case-sensitive version. 
    • Making those two changes the corrected syntax for Windows 10 powershell is:
        cmd /c mklink /J “%APPDATA%\Apple Computer\MobileSync\Backup2” “D:\Users\thowden\AppData\Roaming\Apple Computer\MobileSync\Backup”
    • (Swap the target path for whatever you want to use)
  6. Next I tested by running a backup from iTunes and checking that it was stored in the D: drive.
  7. Finally I deleted the old backups directory from the C: drive.

Side note:  The symbolic link directory is created in the standard path and redirects to the alternative path. The directory (or folder) is created with a Windows shortcut symbol. If you get it wrong, just delete the shortcut, it will not delete the target folder.

So my how to change iTunes backup location on Windows 10 was successful.