Saturday 8 April 2017

Booting Windows 2016 on HP G8 Microserver MicroSD Card

As good as FreeNAS has been, most of the clients on my home network are Windows based and speak CIFS/SMB,  and I've not had great success with FreeNAS reliably/stably serving these protocols.   Under load, the shares sometimes lock up and stop responding, and permissions can be a bit hit and miss.

FreeNAS support forums drink their own special brand of cool aid, so I've decided to try Windows, which, whilst being part of their own borg collective has a much wider base of users and obviously native integration with my client base.  So I'm piloting Windows Server 2016 with its various storage capabilities to see how it compares.

I've got a HP Microserver G8 which as well as 4 disk trays, supports a fifth SATA device via an additional ODD port, an internal USB and a MicroSD port, as well as various external USBs.

My FreeNAS is a previous N54L Microserver, which installs and boots easily to a USB drive, but Windows is a bit more pig-headed at booting from USB/MicroSD devices.
However, with the help of Daniels Tech Blog https://www.danielstechblog.info/how-to-deploy-windows-server-2016-tp3-onto-an-sd-card/  I have managed to get my Microserver booting from the MicroSD Card

Daniels instructions are more or less spot on, except for one change.  
diskpart
list disk
select disk x
clean
create partition primary
format quick fs=ntfs label="SD"
active
assign letter=C
exit
dism /Apply-Image /ImageFile:D:\sources\install.wim /index:2 /ApplyDir:C:
bootsect /nt60 C: /force /mbr
bcdboot C:\Windows
I couldn't get that final line to write to the MicroSD. I kept getting errors about BCDBOOT not being able to write the files, or unable to find the source location. However, I read the documentation about BCDBOOT at Microsofts MSDN site https://msdn.microsoft.com/en-gb/windows/hardware/commercialize/manufacture/desktop/bcdboot-command-line-options-techref-di and happened upon the command for writing to USB devices.

bcdboot C:\Windows /s C: /f ALL

This seems to work fine, and a reboot allows Windows 2016 to boot.

Friday 17 February 2017

Moving Wordpress to a subsite in Azure Websites

Deploying Wordpress in Azure is relatively straightforward.  Deploy a Resource Group, with a DB, and a Web Server using the Wordpress template and bob is your fathers brother.

However, I wanted to move WP to a subdomain which all in all should be pretty straight forward. All the instructions online are out of date or for different systems though, so I wanted to note what I had to set to get it all working.

General Steps are:

1) Deploy your Wordpress site.

2) Go into the WP site and perform the configuration to get it running bare-bones

3) Go back into the Azure Portal and find the FTP configuration

4) Log into the Website with the FTP credentials (I used WinSCP)

5) Copy the entire Wordpress site to your local machine

6) Delete everything from your site except for
              index.php
              azuredeploy.json
              web.config
I had a few problems deleting the wp-admin and wp-content folders - it kept blocking access, but went eventually.

7) Create the name of the subfolder you want to use (in my case /d/)

8) Copy the backup of your Wordpress into the subfolder.

9) Edit the root web.config file.  Mine is setup to redirect all traffic to the /d/ folder.  You many a different setup, but this is mine:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="Root Hit Redirect" stopProcessing="true">
                <match url="^$" />
                <action type="Redirect" url="/d/" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>

 10) Edit the root index.php file and change the require
require( dirname( __FILE__ ) . 'wp-blog-header.php' );
to include the sub folder you want to use.
require( dirname( __FILE__ ) . '/d/wp-blog-header.php' );

11) Azure Wordpress seems to ignore the SQL database setting for the site and home name.  Therefore this must be hardcoded in the wp-config.php file.
Replace the existing paths BELOW the Stop Editing Line! as follows.

define('WP_HOME','http://example.site/d');
define('WP_SITEURL','http://example.site/d');
define('WP_CONTENT_URL', 'http://example.site/d/wp-content');

I also had to define the WP_CONTENT_URL string as my Salient theme wasn't picking up the subpath for some reason, so I hard coded it.

12) The only thing you may have to do is edit the subfolders web.config file.   I was having loads of errors, until I deleted it, then it magically started working.  However, it does seem to have been replaced with an empty web.config file, so its contents are here:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules/>
    </rewrite>
  </system.webServer>

</configuration>

I think that was about it, but it was quite the pain to get it configured.  Nb, if you change the website name or add a custom domain, don't forget you'll have to change the wp-config.php with the new domain name as Azure won't do this for you automatically.

I'm also not sure how things will go when there is a new version available, but hopefully this will get you going.