Categories
Guides Hackintosh Mac

MacOS in Virtualbox. It just works.

You can run MacOS in Virtualbox. Because? Because.

In the pursuit of Hackintosh, you need a Mac. That’s well and great, but I didn’t want to screw around with my partner’s Macbook. So what if you want to sandbox something? Virtualbox!

I had no expectations that this was going to work. OS X has always been runnable in Virtualbox for a while, but the performance has normally been lacklustre. While it’s not exactly daily-driver level, the performance in Virtualbox wasn’t too bad!

The macOS Virtualbox option is designed for genuine Apple hardware. You will not get community support from Virtualbox if you have trouble with this process, as it’s against Apple ToS.

πŸ€”οΈ What do I need?

You need a donor Mac to start this process. You will not need access to it permanently, but just during the process of creating an ISO for your VM to setup with. Else, you need:

This guide will discuss installing MacOS Mojave, however installation process should be similar for all MacOS versions.

⚠️ At the time of writing, Virtualbox and Hyper-V cannot co-exist on Windows. MacOS is also not installable on Hyper-V. I use Linux in my screenshots as I use Docker on Windows. This also includes Windows Subsystem for Linux, which tripped me up from installing.

πŸ’ΏοΈ Creating the ISO

Virtualbox installs generally prefer to use an ISO file, which unfortunately will require some handiwork to get a hold of. Persevere and you will get there!

On the MacOS machine, download the Mojave installer. Don’t worry about actually running this application, as we’re going to use some terminal magic to build the ISO from the package.

This process is not affected by MacOS Installer expiry. If your MacOS installer has expired, you can continue with this guide.

Once the package has been downloaded, pop open Terminal (Utilities folder in Launcher), and run the following commands:

hdiutil create -o /tmp/Mojave.cdr -size 8000m -layout SPUD -fs JHFS+

This will create a virtual ‘disc’ stored in your temporary directory. This is what we’ll stuff the Mojave installation stuff into.

hdiutil attach /tmp/Mojave.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/installer_goes_here

Now MacOS can ‘see’ your disc as an actual disc, ready for writing to!

asr restore -source /Applications/Install\ macOS\ Mojave.app/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/installer_goes_here -noprompt -noverify -erase

We’re now grabbing the installation DMG from within the updater package, and storing it within the disc image. This will rename the disc image, so don’t panic that ‘installer_goes_here’ has vanished.

Now, detach the image from our MacOS. You can just eject it like regular DMGs. If not, run the command:

hdiutil detach /Volumes/OS\ X\ Base\ System

(it may change since OS X is legacy. To check, run ls /Volumes and see if it’s there, renamed).

Now for the final process, let’s convert our CDR image to an ISO!

hdiutil convert /tmp/Mojave.cdr.dmg -format UDTO -o ~/Desktop/Mojave.iso

You should now have a file on the Mac desktop called ‘Mojave.iso’. Congratulations, you have your installation disc! Copy this over to where your Virtualbox is setup. The Mac is no longer needed at this point.

πŸ› οΈ Setting up Virtualbox

⚠️ Before continuing, install the Virtualbox Extension Pack, if you haven’t already. This comes with a special USB 3 driver that without, the Mac simply won’t see USB devices.

Virtualbox has the option for a MacOS virtual machine in it’s New VM dialog, but we will need to make further adjustments to make it truly Mac-ready.

Pop open Virtualbox, and Create a new Virtual Machine. Name this MacOS Mojave, and set it to Mac OS X (64-bit).

Screenshot of the 'Create Virtual Machine' dialog from Virtualbox. In the screenshot, 'name' is set to 'MacOS Mojave', 'Type' is set to 'Mac OS X' and 'Version' is set to 'Mac OS X (64-bit)'.

Set the RAM to 4096 MB (or higher if you can achieve it!).

When creating the disk, you can use either format versions. Dynamic will not immediately take up the storage size you chose, whereas Static immediately reserves the chosen size for the VM. The latter is slightly better for performance.

Screenshot of the 'Create Virtual Hard Disk' dialog, with 40 gigabytes set to the storage size.

Now you should have a new, primed MacOS machine. But you will need to run some commands now. This can be hit-and-miss, and may require some Google-fu. The following works for my AMD FX computer:

VBoxManage modifyvm "MacOS Mojave" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage modifyvm "MacOS Mojave" --cpu-profile "Intel Core i7-6700K"
VBoxManage setextradata "MacOS Mojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "MacOS Mojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "MacOS Mojave" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "MacOS Mojave" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "MacOS Mojave" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

Windows? Change VBoxManage to "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" (if you didn’t change your Virtualbox install location).

The above does the following, in order of command:

  • Sets a known CPU ID set that MacOS will recognise.
  • Especially for AMD machines, changes what MacOS sees as your processor to something it supports.
  • Tells MacOS you’re installing Mojave onto a mid-2010 iMac. You can change this to your preference.
  • These two specify a fake DMI, typically found in Apple PCs.
  • A device key to pass system checks.

Before starting the VM, open the VM settings and make the following changes:

  • System > Processor > Processor(s) is 2 or more.
  • System > Acceleration > uncheck Enable Nested Paging.
  • Display > Screen > Video Memory is 128MB.
  • USB > USB 3.0 Controller.

With all that done, we’re ready to start the VM!

You should be greeted with the following screen:

The 'Select start-up disk' dialog is shown, with the default 'host drive' currently selected.

Click on the folder icon, and find your ISO created on the Mac before, then click Start.

And wait. yes, this process takes a long time. If your installation stops, try googling the last output message to see if there is a community fix, or post below… Otherwise, this is generally a slow process.

If all has gone well, you should be greeted by the MacOS installer language selection. If so, you’re almost there! On the top menu, open Utilities > Disk Utility.

There should be a disk named VBOX HARDDISK or similar. This is the VDI you created during the setup process, and not your actual hard drive. So go ahead and full-erase this disk, with Mac OS Extended (Journaled) and GUID Partition Map.

A screenshot of Disk utility on MacOS, intending to erase VBOX HARDDISK Media. The Name is set to Untitled, Format set to Mac OS Extended (Journaled), and scheme set to GUID Partition Map.

Once the disk formatting has completed, close it down. You should now be able to start the installation!

Once this is complete and you filled all the required details in, congratulations! You’re running MacOS Mojave within Virtualbox!

πŸ‘οΈ What works?

βœ”οΈ Does

  • Screen (No 3D).
  • Regular input methods (mouse sharing).
  • Networking.
  • USB devices.
  • Mac App Store.

❌ Does not

  • Full graphics.
  • Audio.
  • Guest additions.

At the end of the day it’s still a virtual machine, and a technically unsupported one at that. However, considering the matter it’s still impressive how Virtualbox can cope with MacOS.

Files can be shared using typical Windows share features. If you share a folder on your network from your host machine, your Mac VM should be able to connect to it.

🌟️ Special Thanks

This required a lot of Googling, and these are the people who saved me at the end of the process!

πŸ› Troubleshooting

You get Guru Meditation, “A critical error has occurred while running the virtual machine and the machine execution has been stopped” when machine gets to RandomSeed.

This is a difficult one, and will require investigation. I checked the logs as the error message said, and discovered:

HM: HMR3Init: Attempting fall back to NEM: AMD-V is not available

If you’re on an Intel processor, it’ll likely say VT-x instead.

Obviously, check if this is enabled. If you’re on a legacy BIOS computer, it’s a straightfoward scan for AMD-V/VT-x in your settings. If it’s UEFI, you’re gonna have to Google it.

Strangely, on my machine it was enabled. Supposedly Virtualbox and Hyper-V can run side-by-side, so at this point I decided to remove Hyper-V, to see if that would improve. It didn’t, but I forgot something. For this to work, you must turn off Windows Subsystem for Linux!

I completely forgot that WSL uses Hyper-V, and apparently still does when it’s disabled. Unfortunately, it would seem (for me at least) you need to trade it off for macOS in Virtualbox.

I will retest this when WSL2 is launched.

Categories
Hackintosh Mac

Toshiba Satellite Pro L850, Mojave Hackintosh Revisited

Back in 2018 I turned my laptop into a Hackintosh device, running High Sierra. I had a donor MacBook mid-2010 that I used to run TonyMac tools to get Hackintosh working. It was a fun if complicated process of trial and error, but the result was always impressive – a craptop unexpectedly booting macOS.

I eventually wiped macOS and re-installed Windows for a WordCamp coding session. The laptop proved to be quite a letdown, and now sits on a shelf collecting dust.

So, let’s Hackintosh it – again!

πŸ›‘ If You’re Attempting This…

I hate it when some guides forget to do this, but if you want to try this yourself, you absolutely must have the following or you won’t be able to do it:

  • An existing Mac or Hackintosh to build the USB on.
  • A copy of Install macOS Mojave.app. I can’t legally provide mine and they do expire, so fresh is good!
  • My laptop is Toshiba Satellite Pro L850-1UJ. Other L850’s might have a different setup.
  • A large capacity (8GB+) usb storage device.
  • Dedicate the laptop – you will erase everything on it.

If you can’t fufill these, then stop now. You’ll be wasting your time. If you want to see roughly how Hackintosh works or how my experience was, then please read on!

🧐 What Does and Does not Work?

This is from my current setup. They might actually have working configs that I’ve yet to find. If you know any, please comment below!

βœ”οΈ Does

  • Screen (full graphics).
  • Display brightness.
  • Keyboard & trackpad.
  • Battery monitor.
  • USB.
  • Ethernet (fixes AppStore).
  • Speaker audio.

❌ Does not

  • Suspend.
  • WiFi.
  • Keyboard brightness controls.

I happened to have both the Edimax and TP-Link USB wireless adapters, which worked with Chris1111 drivers.

πŸ•“ Changes from 2018

Instead of relying on TonyMac software, I’ve decided to attempt Hackintosh Vanilla. To quote the website:

A vanilla setup implies that the OS itself remains relatively untouched – and that the bulk of the Hackintosh-related kexts, patches, etc are contained on the EFI partition. For all intents and purposes, a vanilla install’s main partition is identical to that of an official Apple computer.

hackintosh.gitbook.io/-r-hackintosh-vanilla-desktop-guide

Other than the different approach, I had the following caveats:

  • Instead of High Sierra, I’m installing Mojave.
  • My MacBook blew up*, so I’m using a combination of Virtualbox and my partner’s Macbook Air.
  • This time, I will not be undoing it. This will be a continuous project until the laptop dies.

*An important point I must raise here. I bought my mac from an eBay listing a few years back. One day I plugged it in and it literally blew up. Smoke came from the plug and I had a residual shock. I put the MacBook and the dead charger in a cupboard and forgot about it. Recently, I pried open the plug to find it was a fake (or a non-recall), and the fuse was bypassed. Please, check your chargers! I now have a plug in RCD when using eBay auction purchases, just in case…

πŸ‘©β€πŸ’» The Process

Setting up a Bootable USB

My trusty SanDisk Cruiser was still lying around, but I’d long since wiped it. So I wiped it without a moment’s consideration of the content (not recommended, of course) and prepped it for being a macOS conduit!

Installer expires?!

Now I keep an archive of macOS installers because… Well, I don’t really know why. Using my partner’s Mac I created a bootable macOS drive using an archived Mojave, only to find I got the error:

This copy of the Install macOS Mojave application is damaged, and can’t be used to install macOS

So it turns out these macOS installers expire! Like a bad carton of milk, macOS would simply refuse to run (other tools like Disk Utility and Terminal were fine). I tried multiple solutions I found on Google to bypass it, but none worked.

It would seem that Apple sign a certificate on the day you downloaded the installer from them. If you wait too long, macOS deems it damaged. You appear to be able to reset the system clock or edit the date via Terminal, but you need to know when your package was signed. Unfortunately, I didn’t note the date down. I discovered however I could re-download it from Apple still. Phew!

Back on track (and still on my partner’s Mac), once I had created the Bootable USB, I used Did’s autobuild of Clover to install Clover onto my USB. Complete shout-out to anyone who works on Clover in any form, as this fantastic bit of kit is what will get your Mac installation drive booting on a PC, and beyond!

In my previous attempt I had a config.plist that worked wonders with my current setup. However, the default config that comes with Did’s Autobuild was apparently completely fine for this laptop. This makes a great starting point!

I ran the Clover Installer package, changed the location to my USB drive, and didn’t change a damn setting. Install, and (safely) yanked that newly primed Hackintosh stick out.

UEFI/BIOS Changes

This laptop comes with UEFI and legacy BIOS mode. Supposedly Clover works with both, but for my install I enabled UEFI mode and disabled safe boot. Saved changes and exited.

Smashing F12 like the refresh button, My trusty Toshiba asked what to boot from. What else but the Macintosh conversion stick?!

I left Clover alone, and it booted straight into the Mac recovery screen. Now, if you’re going to commit to this make damn well sure your Toshiba has nothing important stored on it, and is backed up! This process (or at least how I did it) will erase everything!

Pop open Disk Utility from the Utilities menu. I had to click the button at the top left and show all devices. On my main hard drive (not the USB stick) I selected it and chose erase. I made sure to choose Mac OS Extended (Journaled). APFS might be supported, but I’d rather use the tried-and-true format, and the GUID Partition Map. Hooray, the whole disk is now in Mac format!

Excluding the certificate expiry, the installation ran without a hitch. My network adapters (ethernet and wireless) were not detected so I opted to install without connecting to the internet. I also selected British – PC as my keyboard format, which seems OK except alt and special are swapped round.

Storm through the install like a regular Mac. After a lot of waiting and reboots, you’ll be greeted with the Mac screen. Hooray, you’re done(ish)!

πŸ›  Getting Stuff Working

Most things are working at this point, or at least the most important stuff. Networking, sound, and laptop detection are not.

As a basepoint, I found this config.plist from RehabMan worked well as a jumping point (not to replace the main config.plist).

I used the following kexts (In the EFI partition, in Clover/Kexts/Other):

  • FakeSMC, what doesn’t this one do?
  • Lilu, a dependency for almost all Hackintosh kexts.
  • VoodooPS2Controller, enables keyboard and trackpad.
  • ACPIBatteryManager, battery is detectable by MacOS.
  • NativeBacklight, MacOS detects display has adjustable brightness.
  • OSX Realtek Network, by RehabMan.
  • VoodooHDA for Intel HD Audio out speakers.

Great. With the above, your keyboard, trackpad, audio, battery, brightness & wired network now work.

Native backlighting took some jiggling to get working. RehabMan on TonyMac has a great guide to getting this working (I installed the kext into Clover, not MacOS).

🧐 The Verdict

I’ve actually been finding the performance on this base-spec (inc. original hard drive) runs really well on MacOS. There are slowdowns, and I have not tried gaming on this machine, but nothing more than I would expect from a very old machine. Plus Apple tends to care for their ageing old Intel machines really well, so I’m not too surprised.

The lack of sound and wireless networking is troublesome though. I make do with a USB wireless dongle, but until I can find a solution to let MacOS see my actual WiFi card, I may not be able to upgrade to MacOS Catalina. The lack of ethernet detection also causes problems with the Mac App Store, which seems to always reckon I’m not connected (despite updates downloading just fine).

So, I’m gonna keep it!

πŸ€– The Future

With no dire need to use this laptop (the battery is really dead), I’m going to persist on trying to get Hackintosh to work as much as possible. It really does feel rewarding, and you never get tired of the shock some people have when they see your craptop suddenly boot MacOS.

Although they will question “why not buy a real Mac

Article updates
  • 2020-07-07 – Audio now functions via kext.
  • 2020-07-02 – Updated does/does not work list.
  • 2020-06-14 – Ethernet working with RehabMan’s kext.
Categories
Development Guides

Replace LAMP with Docker, the Easy way

Just about to install LAMP, XAMPP, or MAMP? Stop. Right. Now. Docker’s gotchu, fam.

LAMP stacks are great. They are an absolute fundamental to development, unless you enjoy the thrill of writing your code on your production environments.

Seriously, LAMP is the absolute fundamental in the toolbox for website development.

But do not install it.

Cancel that download, uninstall that software. Because there’s a better solution.

😒 Problems with LAMP

LAMP (XAMPP, MAMP, etc included) kits you out with all the essentials needed for running a website. Web server, language runtime and database. It can come with all the additionals you may need such as email and request logging.

Sounds good. So what’s wrong?

An immediate problem here is that the package you downloaded was tailored for your machine. This is especially a pain point for Windows, which will grab Apache compiled for Windows. More than likely you’ll be deploying to a server running Linux, in which case the environment already does not match. Mac is a lot closer, but is built on BSD which is still not Linux.

The chances of hitting a problem due to mis-matched environments is low, but when dealing with complexities such as encoding, you may experience a problem here.

Oh no, you got a cryptolocker virus! You backed up your code like a good human, flipped the bird at the locker screen, and bought a new laptop. Hooray!

You spend some time to install your chosen LAMP stack again… Wait, why isn’t it working…

Here’s a joyful problem – differences in environment. This can be painful when sharing code, as your great new changes are broken on someone else’s machine. There could be a whole range of causes; The LAMP build you now have has a tiny build problem, Dave gave you a corrupted font file, or you didn’t realise you’re using PHP 5 instead of PHP 7.

Wouldn’t it be great if you could have an environment that each machine could share? This way the machine is identical on each machine, and does not experience this kind of machine-limitation?

Well I have just the solution for you!

πŸ‹ Docker!

Docker is complicated, so I will keep things short and brief. Feel free to shout at me in the comments for it.

Docker runs a small server on your machine, which can run server software as containers. This will split out the tasks into various mini-servers, but share the resources that each container can use. The minature server is set up by your instructions, and these instructions can be shared with others, rather than lugging a whole VM with you.

So with Docker, we can write a file that tells Docker what stuff we need to work our development site, and it will do all the heavy lifting to give you the environment that you need!

ooft, my head…

Docker is complex. However, you don’t need to necessarily understand how it works. This guide will cover the basics needed to achieve what you want, and then you can expand on your learning if you want!

🎼 Docker Compose

Here’s a script, docker-compose.yml

version: '3.6'
services:
  db:
    image: mysql:latest
    environment:
      MYSQL_ROOT_PASSWORD: password
  www:
    depends_on:
    - db
    image: php:latest-apache
    volumes:
    - "./www:/var/www/html"
    ports:
    - 8080:80

Now what does this do?

  • Created two containers – www and db.
  • Grabs the latest Dockerhub images of PHP (using Apache) and MySQL.
  • Sets them up based on their default configs.
  • MySQL sets the admin password to ‘password’ based on our environmental variables.
  • Requests from our local machine port 8080 (http://localhost:8080) are fed into port 80 of our PHP container.
  • A directory called ‘www’ is created in our docker-compose directory. Anything in this folder is now in the web root of our container.

What’s Docker doing?

This powerful little script has just made you a server on your machine that would’ve otherwised taken some time to setup and configure! Yay Docker!

The Docker-compose also creates a network adapter for these containers. What that means is that they can freely talk to each other, but your PC can only see what ports you have bound to it. With the above config, you can access port 80 on your www container easily, but none of the rest. However, the www container can happily chat to the db container without a hitch.

Something important to note – When a Docker container is removed, all the data stored within it is lost. if you wish to keep it, set up a volume binding – like our www container. Anything stored on in a volume isn’t removed when the container dies. In my example, the database is not persisted. In the end example, I’ll show you how to keep it on container deletion.

You can modify the file to add more services if you wish. For example, let’s add mail!

version: '3.6'
services:
  db:
    image: mysql:latest
    environment:
      MYSQL_ROOT_PASSWORD: password
  www:
    depends_on:
    - db
    image: php:latest-apache
    volumes:
    - "./www:/var/www/html"
    ports:
    - 8080:80
  mail:
mail:
    image: mailhog/mailhog:latest
    ports:
    - 8081:8025

Simple! Using Mailhog‘s Dockerhub container, we now have a great development catch-all email server. We can access the GUI via http://localhost:8081, and configure the application to send email to hostname mail on port 1025.

So we got web, db and mail. That’s all well and great. But how do you use it? Simple! Open a command prompt/terminal where your docker-compose file is, and run docker-compose up.

That’s it. Literally.

πŸ’ͺ Full LAMP stack

Okay okay, enough with the lecturing. Here’s a full LAMP stack I whipped up earlier (where’s my Blue Peter badge?).

version: '3.6'
services:
  db:
    image: mysql:latest
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: e9w86036f78sd9
    volumes:
    - "./database:/var/lib/mysql"
  db_pma:
    image: phpmyadmin/phpmyadmin:latest
    depends_on:
    - db
    ports:
    - 8082:80
    environment:
      MYSQL_ROOT_PASSWORD: e9w86036f78sd9
      PMA_USER: root
      PMA_PASSWORD: e9w86036f78sd9
  mail:
    image: mailhog/mailhog:latest
    ports:
    - 8081:8025
  www:
    depends_on:
    - db
    - mail
    image: php:latest-apache
    volumes:
    - "./www:/var/www/html"
    ports:
    - 8080:80

Looks awful, right? Here’s a highighted gist version.

This is what this bad boy does:

  • Creates a MySQL Server.
    • Stored (persisted) in a folder called ‘database’ where your compose file is.
    • The ‘command’ switches new MySQL back to the old auth type, supported by most PHP apps.
  • Creates a phpMyAdmin access point.
    • Web GUI accessible on port 8082.
  • Creates an SMTP Mail Catcher.
    • Configure your apps to send emails to host mail on port 1025, with no authentication.
    • Web GUI accessible on port 8081.
  • Finally, creates a PHP (Apache) frontend.
    • HTTP accessible on port 8080.
    • Uses content found in folder ‘www’ relative to where your compose file is.
    • Loads last, after DB and Mail have been setup by Docker.

Run with docker-compose up and congratulations – You have a development LAMP stack running via Docker!

This will serve you for simple applications, but I absolutely insist that you edit, tinker and break this script to truely discover what Docker can give you. If you mess it up beyond belief, then simply run docker-compose down, and start again!

πŸ› More command info

docker-compose (up/stop/down)

Docker compose is the magical command that translates your yml configuration file into docker commands.

  • up runs the containers detailed in the config file (will create them, or start up stopped containers).
  • stop pauses the containers, like clicking shutdown on your PC.
  • down stops and deletes your containers, ready to start fresh. Data in volumes are not deleted.
  • Bonus: exec <container name> /bin/bash lets you run Linux commands within the container!

If your docker-compose file has a strange name, or isn’t stored where it expects, you can use docker-compose -f /path/to/your/docker-compose.yml. As yml and json are compatible, you an use this command to write your compose file in JSON notation.

Make sure when running these commands, your terminal is local to where the docker-compose file is. Also, my script will create folders relative to where docker-compose file is. You can modify the volume paths to change this.

πŸ‘ Closing Notes

The great level of flexibility with docker-compose files lets you think outside of the box. With a traditional LAMP stack, you would install it then stuff your PHP scripts into it’s www/htdocs directory. With Compose, you can actually create the docker-compose.yml inside your project directory, and tailor the script around it.

Confused? Say you wrote a WordPress plugin. You can craft your docker-compose to setup a full WordPress environment, and bind the project directory into the WordPress plugin dir. You can then access WordPress with your plugin already loaded in!

So get creative with your newfound Docker experience, and let me know what you achieve with Docker. I’m also by no means an expert, so if I’ve missed something please give me a shout and I’ll revision this with all the great stuff you find!

Categories
Development Guides Windows

The Complete Guide to Running WordPress on Windows/IIS

So you’ve discovered to your absolute horror that the WordPress site your company has inherited is running on Windows… on IIS?

Before you stand up, throw your computer chair out the Window, maliciously eat your co-workers salad and enjoy it, or drop all the production databases, relax. We’ve got you covered.

🀷 What’s the problem?

Good point. IIS (Information Internet Services) is the home-grown proprietary (for now) web server provided by Microsoft for Windows customers. IIS is fantastic at what it does, and can serve as an efficient web host as well as an absolutely golden reverse proxy server.

So what’s the problem?

πŸ™…πŸΎ Support

Zilch. Nada. No dice. WordPress is absolutely not designed to be run on IIS and probably never will be. This doesn’t mean your server is going to burst into flames when you run the site, but means that when support is needed you can be damn well sure your first bit of advice will be “don’t use Windows”.

So don’t use IIS? Simple?

Except that currently NGINX is crippled on Windows (source), and Apache, which is thankfully available on Windows via unofficial channels… But you still have very little support since it operates differently being on Windows.

However, WordPress requirements state:

We recommend Apache or Nginx as the most robust and featureful server for running WordPress, but any server that supports PHP and MySQL will do.

– so don’t lose hope just yet.

πŸ“‚ The web.config File

If you’re coming from an Apache background, you might be used to a .htaccess file. Just like how .htaccess is not compatible with NGINX, it is also not compatible with IIS.

For each folder of importance to IIS, a web.config file will appear in the directory. This tells IIS what fancy features and involvement the folder has with web capabilities. It will store everything configuration-wise, so do be careful not to delete or corrupt this file.

web.config is an XML file, and can be easily edited in an editor of your choice. Once you get very comfortable with IIS, you’ll find yourself editing the file manually more often than using the GUI console. This will also to reduce the management overhead of changing IIS settings.

An example of useful properties stored in here are:

  • Priority list of the default index to load.
  • URL rewrite/redirect rules.
  • Request filtering, blocking and setting adjustments.
  • Directory over-riding of parential settings (e.g. PHP Version).

βš™οΈ Setting up WordPress

First you will need a database. It is recommended you have the database on a different server for performance and security reasons, but you can also have MySQL running on the same server as IIS.

MySQL runs well on Windows, and is very well supported. You shouldn’t expect much push-back in the way of configuring MySQL. However, if you wish to use Microsoft SQL Server, you may wish to check out Project Nami.

Once completed, setup a database and access user like you would a Linux-based setup installation.

Also, while it’s best to always be running the latest version of Windows Server, please consider using a version no later than IIS 10 (Windows Server 2016). This is because older versions of IIS do not have support for HTTP/2. Technically speaking the minimum requirement is IIS 7 (Windows Server 2008).

🐘 PHP on Windows/IIS

Prerequisites

You will need to configure IIS to use CGI processing for IIS (which isn’t enabled on default IIS installations).

You also need the URL Rewriting module for IIS, unless you are planning on using those super ugly index.php URLs.

PHP is fully supported on Windows. To download PHP, visit their website at windows.php.net. You will also need the C++ Redist 2019 which is found on the sidebar on their website downloads.

This guide will use FastCGI, which will require a Non-thread safe version (NTS) of PHP. Typically the first download listed in each PHP version on their site will be the ideal version for IIS.

Download the correct zip file and extract it to a place of your choice on your server (Program Files is acceptable). My choice is normally C:\PHP\X.X.X (version number).

If you’re planning on running any PHP tools such as WP-CLI, it would also be a good idea to add the above path to your system Path environmental variable.

To do so, open Run (Win key + R), and run rundll32 sysdm.cpl,EditEnvironmentVariables. Append the path to Path found under System variables.

Installing WP-CLI (optional)

Now is a good time to install WordPress CLI if you’re planning on using it. They provide a fantastic guide to setting up WP-CLI on Windows.

Web Platform Installer – Easy

Windows Server has an optional comonent called the Web Platform Installer. This neat application provides a collection of the most well-known and loved software packages, and provides super-easy methods of installing them. Guess what, WordPress included! You just need to install IIS with CGI first.

Create a Site as regular, and double-click on it. You should have an option in Management called Web Platform Installer (at time of writing, it’s a circular, orange download icon). Open this up, and a new panel will load up. Search for WordPress, click Add, then Install.

❓ No Web Platform Installer? It’s not installed by default. Click your server name in the Connections left-hand panel. In the now-visible right-hand panel, click on Get New Web Platform Components. Follow the Microsoft instructions and you’ll have the aforementioned button.

Now for configurations, you should generally always separate up your servers (e.g. web and database are separate). But sometimes, you just want a get going quickly on a development site. This installer has a neat trick. If you do not have a database server, and the current machine doesn’t have MySQL installed, it will create a MySQL server instance for you!

If done correctly, you should be at this screen. It will by default try to create localhost/wordpress. Make sure you’ve got the right Web Site selected, and – if desired – the right subfolder configuration. If something is wrong, it will need to be changed manually afterwards.

Hit Continue, and go grab a coffee. When you return, WordPress is installed! Easy as that, you’ve got your first WordPress installation.

For the technical information:

  • Microsoft WebMatrix is installed.
  • ❗ PHP 7.1 is installed via IIS Express.
    • A newer version of PHP is recommended.
  • A global FastCGIModule for PHP is created.
    • This means all sites on your IIS server can run PHP code via this module. Change priority listings if you wish to run different versions.
    • You can use the PHP Manager or manual process to over-ride this.
  • MySQL 5.1 is installed, if no external database was provided.

PHP Manager IIS Plugin – Intermediate

There is a plugin for IIS called PHP Manager, which is able to do most of the heavy-lifting for you in configuring PHP. This will enable you to register new PHP versions, adjust plugins, edit configurations and even split containers to different IIS versions as simply as possible via GUI.

Simply download their extension and install it on your server. When you next run IIS you will find a new PHP module on the snap-in.

You can register a parent PHP version and it will affect all children sites. If you register an alternative version on a child site, it will over-ride the parent and so on, in a hierarchical manner. Multi-version PHP, hooray a benefit!

PHP Manually – Advanced

If you opt not to go for IIS manager (not a fan of community IIS modules), then you can still go ahead configuring PHP manually to the IIS container.

First you need to tell the FastCGI system about your PHP installation.

  • Open IIS.
  • Click on the root server (just below Start Page on the left pane).
  • Open FastCGI Settings.
  • On the right hand side, click on Add Application…
  • In Full Path, navigate to php-cgi.exe in your extracted php setup.
  • In Monitor changes to file, set this to your php.ini file.
  • Click on … on the end of the row named Environmental Variables.
  • Click Add.
  • Add PHPRC variable with the value of the PHP installation path, where your PHP-CGI file was above.
  • Create another variable named PHP_FCGI_MAX_REQUESTS, and match it to the value in Instance MaxRequests (recommendation for both is 10000).
  • Click OK.

Cool! IIS now knows that your PHP folder is a CGI process, it now knows how to handle requests to PHP with this processor. Now let’s set up the individual website to use PHP CGI.

  • Find your container in IIS (e.g. Default Web Site) and click it.
  • Open Handler Mappings.
  • On the right-hand side, choose ‘Add Module Mapping‘.
  • Add the following entry:
    • *.php for Request Path.
    • FastCgiModule for Module.
    • Path to your PHP CGI for Executable.
    • Whatever you want for Name.
  • Head back, and go into Default document.
  • Add index.php to the list (your choice).
  • Test in your browser if PHP loads up.
    • Try index.php file with <?php phpinfo();

If you do the above for the topmost entry (normally your machine name), it will copy to all new containers, so you don’t need to do this process for each site.

Recommended php.ini Configuration

The perfect php.ini configuration is very much a game of trial and error. Believe me, it’s difficult to find the best config balance when it comes to PHP, WordPress and Windows. Here are some essentials:

  • cgi.force.redirect = 0 (essential!).
  • fastcgi.impersonate = 1
  • extension_dir = <Absolute path to install>/ext

These are set when using PHP Manager. This configures PHP to understand that it is operating via CGI mode. The second configuration also helps to link the PHP operations into how IIS works, enabling better interop between PHP and IIS.

The third is recommended especially if your PHP installation is not located on the C drive. Absolute stops PHP trying to interpret where the extension dir is, which is can get very wrong if not located on the C drive.

Setting up WordPress

Now for an easy part – the WordPress installation! Thankfully this is as easy to do, if not easier than the Linux server counterpart.

Create your desired site in IIS. If you’re binding this a domain or subdomain, create a new site. Otherwise, you can create a subfolder (or virtual subfolder) in IIS to setup a subfolder WordPress installation.

In the folder you bound to the container, extract the WordPress installation zip (or use WP-CLI if installed earlier). If done correctly when you visit the URL in the browser you will see the good ol’ 5 minute installation screen.

Run through the installation as per a normal site, and congratulations – you have a WordPress site running on IIS!

⭐ Special Thanks

In the hopes of keeping the information up to date and relevant, the following commenters below have helped keep me in check:

  • Patrick Bates for pointing out Web Platform Installer.
  • John Wilkin for pointing out I did not cover web.config.

ℹ️ FAQ

I received an error: 500 The FastCGI Processed exited unexpectedly.

Each version of PHP for Windows depends on a Visual C++ Redist package, which is mentioned in the download title. Normally recieving this error means your system does not have the one it needs, causing the CGI process to error.

In each download segment on the downloads website, check for VCXX (X being numerical). The left-hand sidebar will tell you which redistributable package you need and how to obtain it. Once installed, this error will stop.

If – for whatever reason – you are installing the Legacy 5.6 releases, download the 32-bit redistributable, regardless of your server architecture type.

I recieved an error: 500.21 Handler “xyz” has a bad module “FastCGIModule” in its module list.

When installing Internet Information Services (IIS), PHP runs through CGI. This lets IIS pass the processing of non-Microsoft language code to it’s relevant processor. For us, it enables IIS to chuck .php code at PHP.

This error simply means that the CGI module it uses (FastCGI) was not installed. This is easily fixed!

Open up Server Manager. At the top right, open up Manage, then Add Roles and Features.

Next next next it through until you get to Roles. In Web Server (IIS) > Web Server > Application Development > Check CGI. Click Install (or next until you can), and your IIS server should now support CGI, including FastCGI

Pretty Permalinks, and .htaccess

WordPress is smart enough to know it’s on IIS, so when you go to adjust permalinks instead of creating .htaccess, they will create a web.config file, which is the IIS equivalent. If you need additional rules the IIS rewrite module can attempt to parse your htaccess file in the IIS module.

If you create a .htaccess file, it will be ignored – IIS rewrite can attempt to convert these files, but not use them.

How do I disable xmlrpc via IIS?

In my years of WordPress, this only recently popped up for me – people abusing the xmlrpc.php interface. There’s a range of options to deal with this in WordPress, but they all involve WordPress loading. I personally think it’s better to use IIS to block the interface instead.

Via web.config

Locate the <system.webServer> block, and add this (normally at the bottom):

<security>
  <requestFiltering>
    <denyUrlSequences>
      <add sequence="xmlrpc.php" />
    </denyUrlSequences>
  </requestFiltering>
</security>

Any contoso.com/xmlrpc.php request will now serve a request denied error, instead of passing through to the interface. This stops WordPress processing said requests, therefore stop wasting processing power on these bogus requests.

How do I set permissions?

The container will default to using the account IUSR, which won’t have access rights by default. For starting out, you could simply give IUSR full permissions to the folder, and your website will work. Updates will occur, cache will write, all gold.

This sometimes does not work, in which an alternative you can do is change Anonymous authentication in Authentication on the container to Application Pool identity, and give IUSRS group full access.

Both of these are not recommended for production use, as in the event of a compromise the hacker will have full write access. You can check out the guide on permissions from WordPress, as the permission fundamentals are similar.

How do I enable HTTP/2?

HTTP/2 is only supported in IIS 10 or above, which requires Windows Server 2016 or higher.

How do I increase the runtime limits?

In PHP Manager, on the container you wish to adjust, click on Set runtime limits. This will show the php.ini config options to quickly change these limits. For everyone else, you can find the limits within php.ini like always.

If you wish to increase the maximum execution time, please note that both PHP and IIS track timeouts differently. As well as increasing this via either PHP Manager or php.ini, you will need to tell IIS too.

Pop over to the root (underneath Start Page on the left panel in IIS). Open FastCGI Settings, and find the CGI you wish to modify. Click edit, and you should see two settings called Activity Timeout and Request Timeout. Set these both to whatever limit you want, and make sure all three (inc. PHP’s max_execution_time) match. Your timeout should now be sufficiently increased!

Should I choose Windows over Linux for WordPress?

No. Absolutely not.

Can I hook WordPress into Microsoft SQL Server?

Project Nami is a fork of WordPress that is designed to work with Microsoft SQL Server in place of MySQL. This team has replaced all MySQL functionality and added some beneficial functionality from SQL Server. This is well worth checking out!

Can I run multiple versions of PHP?

Yes! Arguably this is one of the only benefits of running PHP on IIS, you can run multiple PHP versions.

When you are looking at the Module Mappings segment (either site or server-wide), there should be an option on the right-hand side column that says View Ordered List…. The topmost version of PHP will be the chosen version, so use this to your advantage to change which version your site operates with.

Article was updated on the 21st June 2020 to elaborate on the web.config file, and cover WMI deployment.

Categories
Linux

Linux it up like 2008 with Wubi, which still exists

Wubi was Marmite back in the day. With Linux being pitched as an alternative to Windows, people weren’t particularly impressed with using Microsoft technology to boot up a virtual Linux installation. Alongside the genuine concern that a power outage would obliterate your Linux setup, Wubi faced a lot of criticism.

Wubi installed a full desktop Ubuntu installation inside a virtual hard drive on your Windows machine. Yep, you could literally install Ubuntu like a regular application, and boot into a full Ubuntu OS instead of Windows. Dual booting went from being a nightmarish partition juggle of your main drive, to a literal one-click install.

Wubi fell out of favour around 2012 as the Ubuntu installer made hard drive partitioning ridiculously easy, and virtualisation stopped tanking your PC. But the advent of UEFI pushed Ubuntu back from super easy installation, into needing some technical know-how to setup. A correct setup was also devoid of the Wubi problems such as power outage corruption and NTFS performance impacts.

With a reduced interest in Wubi, development stopped… Until now… Ish.

Welcome, Wubiuefi!

🧐 What does WubiUEFI do?

WubiUEFI installs a full Ubuntu flavour into a virtual hard drive, stored on your Windows machine. It then instructs Windows to add an entry to your bootloader to boot up the installation on this virtual drive.

Literally that simple.

πŸ’© What’s the Catch?

The hard drive you boot from is a virtual disk, which is being accessed via a Windows NTFS layer. This adds a small speed overhead that you will notice when WubiUEFI is installed to a hard drive, rather than an SSD. This also makes the system a lot more suceptible to data corruption in the event of a hard power off, like a power cut.

It can also be a pain to configure on a UEFI system with secure boot enabled, but not impossible to do.

πŸ–₯️ Will WubiUEFI break Windows?

WubiUEFI depends on Windows so you can rest assured it absolutely will not break your Windows installation! Ubuntu is installed into a file, not a partition. In other words, this won’t fiddle around with how your system fundamentally works.

WubiUEFI will add an extra item to the Windows bootloader, so when you boot up your PC it will ask if you want to reboot into your Linux install instead of continuing into Windows.

❌ Can I remove it easily?

Probably one of the best things about a WubiUEFI installation, yes! Removing WubiUEFI installations is done by simply popping open Programs in settings, and uninstalling Ubuntu! Job done.

If you want to do the reverse however, you may be out of luck. While it’s possible, it’s an incredibly long-winded and risky approach. It has be done before on older versions, but your mileage may vary. A full manual installation would be recommended if you wish to move away from Windows.

After some jiggery-pokery, my finished Wubi-installed Kubuntu.

πŸ’‘ What’s WubiUEFI good for?

WubiUEFI is absolutely fantastic for giving Ubuntu an extended trial without the lack of storage from running a LiveUSB. Even better for giving various different flavours a try, as you can dispose of the installation afterwards should you not like it.

Note that on a decent/fast machine, it may be more preferable to install Ubuntu in a virtual machine, as you will not have to leave Windows for this.

If you’re a person who tends to store all their important files aside from the main OS drive, and don’t mind the potential data loss from a power loss, this is a quick and easy way for you to install Ubuntu dual boot without having to mess up your partitioning.

And – lastly – because you can!

πŸ’ͺ I’m convinced – How do I WubiUEFI up my PC?

Pop over to Hakuna-m’s GitHub page to find the WubiUEFI installer downloads.

A lot of work has been put into supporting a vast array of BIOS and distributions, but before continuing check out this FAQ entry to find out if you have secure boot enabled. If you do, you may want to read the wiki entry on working with secure boot as it may get technical and is not for the faint-hearted.

The links will take you to the release you desired. Download the .exe file from under Assets, and give it a run. Fill in the details of which distro you want, what size and where to store the files, the system will begin to download and prepare your Linux distribution.

If your connection is slow, you may get an error when setup begins. In which case the developer recommends pre-downloading the ISO from the flavour’s website, and keeping it in the same folder as the installer. In which case it’ll use that instead of downloading one.

If all goes well and you reboot, you may end up in the Linux system. Don’t panic! Windows hasn’t gone anywhere – first boot on EFI systems will load up Linux, and subsequent reboots will load Windows first.

Let the installation finish and you’ll now have the option of Windows or Ubuntu on your Windows/UEFI bootloader! Neat!

Bored of Linux? Pop open Uninstall programs and features, and remove Ubuntu. It’s that simple.

There’s no option for Ubuntu on reboot…

Some UEFI systems will handle the OS choice itself, which is especially true of store-bought machines, new motherboards and laptops. When you boot and the manufacturer logo appears, but before the rotating dots do, repeatedly press either Esc, Del, or F12. One combo will eventually boot you into a menu that will ask what you wish to start, with Ubuntu hopefully being an option.

I got a big ol’ Access Denied error

I’ll pass you over to their Wiki page which covers this in detail. Prepare to get technical.

Categories
Development

Use Visual Studio Code in your browser, thanks to Azure

Yes, the Electron-based Visual Studio Code – an app built in HTML and JavaScript – is not usable in a web browser. What a weird world we live in.

You may sitting there in your coffee shop, staring with contempt at your weakling tablet and thinking “boy, I wish I could run Visual Studio Code on this powerful lemon”. Well Microsoft apparently listened to you and your gaping wallet. You can now use Visual Studio Code, online!

The aptly named Visual Studio Online – designed to confuse the real Visual Studio developers up and down the land – runs the full Visual Studio Code experience within your web browser. But how, you probably didn’t ask?

Visual Studio Online hooks up to a Azure cloud instance that will run a full copy of Visual Studio Code. Basically, the web version (basically a pseudo-copy) will stream all the changes back to this real copy. Woohoo, programming – Netflix style!

πŸ’ΈBut I’m too poor to afford Azure…

Don’t worry, my financially-challenged friend. No regular human can afford Azure.

You can install Visual Studio Online plugin on a computer of choice, and use that as your streamable programming buddy. This means you can use your home PC, a virtual machine, Raspberry Pi, just about anything that can run the latest version of Visual Studio Code.

To do this, you still need a Microsoft Azure account on a minimum subscription of pay-as-you-go. You don’t have to rent out any of their expensive packages, you just need the account to link your remote VSCode setup to.

πŸ‘€ First Impressions

Microsoft are keen to point out this is insider quality, and is not yet ready for production usage. This is also made obvious by the fact it is not compatible with Firefox. Likely this stems from the regular editor being built upon Electron.

I tried this out by setting up an Ubuntu Hyper-V container, installing Visual Studio Code with Online, and hooking it up to my Azure account.

As far as what I tried, it works just as I would expect the desktop version to work. Extensions all appear to be the same, project and installation settings work (I assume client settings are per-browser, as it lost mine frequently), and the terminal works really well on the existing machine.

This works really well combined with Docker and ngrok, or with a forwarded port open via the home broadband router. All my extensions were compatible, and even Intellisense kept up well despite both a struggling VM and broadband.

This currently isn’t mobile friendly, so don’t expect to do any on-the-fly miracles with your phone. However, this works a treat on tablets for those remote working moments without a primary machine.

I’m really impressed with Visual Studio Online so far, and I can categorically say this will replace my AWS Cloud9 via SSH editor that I used to use.

Any thoughts, or want me to try anything out? Please, let me know via the comments below!

Categories
Hackintosh Mac

Hackintoshing a Toshiba Satellite Pro L850-1UJ

⚠ This project has been resumed. Please see the latest version of this.

While I am a technical person, the Hackintosh community is scores ahead of what I know. The work put in by the awesome community supporting the Β movement for macOS/OS X on other machines is incredible. I’ve watched the progress since I was 11, but never branched into it. Recently, it all changed.

macOS High Sierra about screenshot, showing the version details
My Toshiba pretending to be a MacBook Pro

I write this now on a Hackintosh laptop. This isn’t any old laptop however… This is a laptop that is not technically supported. I googled for hours to see the achievements of other Satellite owners and found nothing. However, with trial and error (and years of configuring crap experience), I was graced with the Apple logo appearing on my non-Apple laptop.

Notice: Since 2019 I have removed Hackintosh from my laptop, this is primarily as I have received by MacBook White back and so now use the laptop for Linux distributions instead.

Notice: Since 2020, my MacBook white exploded so I’ve returned to this, which can be seen here (Hackintosh, not my laptop exploding).

Back Story

I recently traded my trusty MacBook White mid-2010 for my girlfriend’s university laptop Toshiba Satellite Pro L850. Since leaving uni she no longer needed a laptop in general, and was happy to take a lower-spec Apple machine to compliment her iPhone. Receiving a much higher spec machine in return, we swapped. I immediately (no joke – first two hours of receiving it) turned it into a Linux machine, using Ubuntu and later, elementaryOS.

I then wished to contribute to a Windows extension development, in which I needed Windows again for. eyeing up the old trusty Mac again, I realised I was in the best position to Hackintosh – pre-existing Mac and a machine that can be clean-wiped. And so it began.

How?

I would like to take this moment to say this would not be possible without the amazing community work that goes into it. I simply configured this laptop to use Hackintosh, the real developers and hard-workers can all be found at the TonyMac86 community. If you’re impressed by this, or tried it yourself, please direct all the praise to those amazing people.

What Does & Doesn’t Work

Take this with a pinch of salt, as Apple never intended for you to install this. Whatever does work is an absolute miracle, and often smaller problems can be overcome with additional hardware.

Initial issues with graphics

Does Work

  • Main Display Graphics (Intel HD 4000) with Clover config.
  • Keyboard (set to ISO, keys don’t match up 100%) and trackpad.
  • Wireless Internet (temporarily, resorted to dongle).
  • Battery status.
  • USB ports (you wouldn’t believe how problematic that can be).
  • CD/DVD drive.
  • Webcam.

Doesn’t Work

  • Laptop Detection, for power management (In Progress).
  • Brightness Controls (In Progress).
  • Standby (Kernel Panic).
  • Brightness controls (Lucky for me, seemingly defaults to mid brightness).
  • Sound (Untested, does seem to be fixable).

For most of the non-working elements, any USB peripherals claiming to be Mac-compliant should work in their place. Your experience may differ.

Quick Steps

  • Enabled UEFI, but disabled secure boot in BIOS.
  • Download the macOS High Sierra installer from the App Store, on the existing Mac.
  • Download and run Unibeast (set for UEFI).
    • Also copy Multibeast onto USB.
    • While EFI is apparently mounted, I copied over the neccessary kexts and this configuration file into the CLOVER directory (don’t replace the existing config.plist).
  • Make a cup of tea.
  • Drink said tea.
  • Plug USB Stick in Toshiba, repeatedly tap F12 on boot, and boot via USB.
  • In Clover, go to options, config, and select the configuration you copied earlier (most likely, the currently deselected one).
  • Select ‘Boot from Install macOS High Sierra’.
  • Wait (another tea moment) for macOS to start.
  • Open Disk Utility (click View > Show All Devices at the top).
  • Select TOSHIBA and click erase.
    • I erased the entire hard drive. If you wish to keep stuff or dual boot, please see a guide for dual booting as this will erase everything.
  • I chose single HFS+ partition (I named it the classic Macintosh HD), with a GUID partition map.
  • Once complete, run the installer.
  • Once finished, boot via USB stick again.
  • Same again with Clover, this time select ‘Boot from <partition name>’.
  • Congratulations – You’re running macOS!
    • You will be reliant on the USB key to boot. Check out Remove USB Reliance to stop doing this.
  • (Optional) Setup Windows dual boot.

Many, many, many steps to go through, but so long as everything is done correctly, this should be a completely rewarding experience afterwards.

Required Kexts

Kexts are basically driver packages used by macOS to understand what your various input devices are telling it. Without usable kexts, if macOS doesn’t know what a device does it will simply ignore it. There’s no Windows Update to grab them for you.

Clover and Unibeast does a Hell of a job packaging all the essentials in to your USB key, but especially for this laptop there are some missing essentials. Most notably, the keyboard and trackpad won’t work, which can make things slightly problematic.

The following are the kexts I have successfully added and used with my installation:

Instead of installing them on the system, I opted (and is not recommended) to install them into Clover. Clover will inject these on boot, so you never need to install them in Mac and risk update breakage. The big downside however is that you risk breaking the boot process, which can make things tricky to resolve. My personal approach is to try riskier kexts on the USB Clover first, and if successful I then copy them to the HD Clover. You can also tell Clover to boot without these kexts, but this may leave FakeSMC behind and refuse to boot.

If you wish to install kexts to Clover, then grab this utility to mount your EFI partition. Then you can whack your additional kext files into CLOVER > kexts > Other. Clover will then inject these into the boot process.

My Macintosh HD EFI layout

Boot via Hard Drive

If you haven’t already got frustrated about needing to boot via USB, then your patience knows no bounds. However, you can set up Clover to reside on your main hard drive EFI partition rather than just the USB drive.

Personally, if you can do so I would recommend either leaving the USB drive as it is or taking an image backup after successfully being able to boot via Hard Drive. The reason being is that you can use this memory stick as a rescue device, and boot your laptop again in case a faulty configuration or a software update kills the boot process. 

In the quick steps you would have a copy of Multibeast if followed to the letter. You can use this to modify your Hackintosh configuration, and one of the major features is the ability to install Clover on the working drive.

In Multibeast, click on Bootloader, and then Clover UEFI (Legacy if you did not enable UEFI). Then click build. Once finished, your EFI partition on your main disk will have its own bootable Clover. Don’t stop just yet though.

Plug in your bootable USB Installer drive and use the EFI Mounter utility to mount the EFI partition on your USB drive. Grab both the config.plist you select on boot and all the kexts from ‘Other’. Now eject the USB Drive, and run the utility again to mount the EFI partition of your hard drive. Simply copy these files to the same places they were at on your USB drive.

So far, on each boot up I currently go into Config and change the config selection. There are ways to modify the main config to boot straight into macOS, however all my config file modifications ended in disaster, so I’ve kept it operating this way.

Personal Verdict

Hackintosh deserves a new name. While originally it was a small list of supported machines, today the amount of eligible machines is insane. As long as the system remains stable to use, then I would absolutely continue to use macOS as my primary. 

If you have a spare laptop and technical expertise, I would totally recommend trying it out. The experience is rewarding, and slightly baffling at the same time. Nothing is weirder than seeing the macOS login appear without the use of virtualization technology.

Last Changed: 25th April 2020 (now tracked elsewhere).

Categories
Development

Using PHP 7 on Ubuntu 14.04 with Codeanywhere

I am a big fan of online IDEs. For me this enables me to do web development pretty much anywhere, on any device. My particular favourites are Codeanywhere and Codenvy. While both have their pros and cons, I pretty much use Codeanywhere free for my day-to-day development. It gives you a temporary VPS for your code, easily accessible, great no-nonsense IDE and easy to use SSH access. Perfect, I simply fire up the container and get to work.

I do have a problem with it however, and it isn’t something you can fault them for – Ubuntu 14.04. I love every release of Ubuntu, but nobody should be running PHP 5.4, which has been EOL for a long while now. PHP has made some massive strides since then with PHP 7, with 7.2 being the currently latest iteration. So the first thing I do is get the container as up to date as I possibly can get it.

They do have a PHP 7 container available if you go down the CentOS route, but I personally encountered dependency issues running their version. However your milage may vary, so if you are a fan of CentOS, you don’t need to continue.

Container Creation and Update

Once you’ve logged in to Codeanywhere, it will ask you what container you want to setup (otherwise, File > New Connection > Container).  In this instance, we will select the Ubuntu 14.04 version of the PHP containers.

Screenshot of Codeanywhere container screen showing PHP options

Once finished, you’ll have your own personal VPS for your project(s). Before we do anything, we need to make sure your Ubuntu box is up-to-date. For this we need to run the commands that every Ubuntu sysadmin is familiar with:

sudo apt update && sudo apt upgrade -y

‘update’ will tell your VPS what new updates are available, and upgrade will upgrade said packages (-y stops it asking if you want to proceed, if you do want to check it before installation then remove this).

In my scenario, it asks if you want to replace some pre-existing system configuration files. You can simply press Enter and skip through these.

Once finished, you’ll have an up-to-date container. We can now move up to PHP 7.

Updating PHP 5.4 to PHP 7

The current repositories for 14.04 do not use PHP 7, supporting 5.4 as the maximum. So we need to add a new repository to do this. Now, for some reason certain system functionality from base Linux have been removed, so we need to re-add these features. Use the following command:

sudo apt install -y software-properties-common

We now need to add a repository that supports PHP 7 in 14.04. In comes Ondrej, a PPA repository that does just that!

sudo apt install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt upgrade -y

Normally the LC_ALL line is not needed. However, in this repository some characters are used in the description which breaks with non-UTF8 languages. The extra command parts will make sure it uses UTF8 to process it, and go through fine.

Once all commands are run, your system will be running the latest available PHP version. However, Apache will still be using PHP 5.4. Command line PHP works great for tools such as Composer and PHPUnit, but our application will not use it until Apache knows it exists.

We need to install some additional PHP modules for Apache to recognise it, which can be done by this command:

sudo apt install php7.2 php7.2-mbstring

Add php7.2-mysql if you use MySQL, or add others for the extensions you need. Use sudo apt search php7.2 to find out what’s available)

Now we need to command Apache to ditch PHP 5 and use PHP 7.2, so run the following commands.

sudo a2dismod php5 && sudo a2enmod php7.2

Now restart Apache to make sure the changes are fully committed.

sudo service apache2 restart

Now you should be ready to develop using the latest version of PHP. With this repository, you should also receive the latest updates to PHP whenever you run the update command, so you should be good going forward!

Checking PHP Version

If you want to check which version of PHP you’re running, then you need to do it twice. PHP can often be used in command line as well as on a back-end server techonology like Apache or NGINX. It is possible for your Linux installation to use one version of PHP, and your web server application to use another.

To check your command line PHP version, simply run the following command:

php -v

To check the Apache version of PHP, create a new PHP file in the root of your workspace (say, info.php). Paste the following into the file.

<?php phpinfo();

Now browse to it in your browser (right click the container, and click run. Then, add /info.php at the end of the URL). It should give you a full dump of the server technology, with the version right at the top.

Bonus – Quick WordPress Installation

This will install WordPress to /wordpress directory of your cabox. Run this command first which will set up the brilliant WP-CLI on your container.

sudo wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp && sudo chmod +x /usr/local/bin/wp

And this can be used to create our WordPress installation. Run in the workspace folder (Run cd ~/workspace if you’re unsure). Change theurlhere.com to the domain of your container, plus the /wordpress.

mysql -u root -e "CREATE DATABASE wordpress01;" && mkdir wordpress && cd wordpress && wp core download && wp config create --dbname=wordpress01 --dbuser=root && wp core install --url=theurlhere.com/wordpress --title="WordPress Development" --admin_user=admin --admin_password=password [email protected] && sudo chown www-data:www-data *

This cuts down the famous 5 minute installation to about 15 seconds. Since this is development, I’ve kept things basic with the admin password simply being password.