Getting Craft V2 To Work On Homestead

As of Homestead v0.4.2 mcrypt was added back so that fixes the first issue I had when trying to get Statamic V1 and Craft 2.0 working. There was then a second issue with Craft that had me wanting to throw the towel in with Homestead. I was getting a couple of database errors on install:

[error] [system.db.CDbCommand] CDbCommand::fetchAll() failed: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #18 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'craft_test.structureelements.root' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by. The SQL statement executed was: SELECT `elements`.`id`, `elements`.`type`, `elements`.`enabled`, `elements`.`archived`, `elements`.`dateCreated`, `elements`.`dateUpdated`, `elements_i18n`.`slug`, `elements_i18n`.`uri`, `elements_i18n`.`enabled` AS `localeEnabled`, `content`.`id` AS `contentId`, `content`.`title`, `content`.`field_body`, `entries`.`sectionId`, `entries`.`typeId`, `entries`.`authorId`, `entries`.`postDate`, `entries`.`expiryDate`, `structureelements`.`root`, `structureelements`.`lft`, `structureelements`.`rgt`, `structureelements`.`level`

AND

2016/03/05 08:15:10 [error] [exception.CDbException] CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #18 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'craft_test.structureelements.root' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by in /home/vagrant/Code/craft-test/craft/app/framework/db/CDbCommand.php:543

These are apparently fixed for Craft 3 as its to do with the version of MYSQL you are running:

MySQL 5.7.5+ changed the way GROUP BY behaved in order to be SQL99 compliant (where in previous versions it was not).

After a bit of digging I found this useful article on the Craft Stack Exchange. You have to scroll down to find the Homestead specific help but it basically points to the missing fix which Jacob Graf kindly posted on Medium.

After adding the fix provided by Jacob everything should be up and running.