Apple’s new M1 chip, also known as the Apple Silicon, is running on a different architecture (known as ARM-64) than the previous generation. While they have provided an emulation layer, some tools are not ready yet. Importantly, there are upstream dependencies in Lando and Docker that we require that are simply not viable in an emulation layer. This blog provides the steps to getting a development environment running for work without using those tools.
Applications
Most compiled commercially available or open-source applications are running pretty well right now, either by way of updates from the developers, or by way of Rosetta, Apple’s emulation layer.
Fully compatible
Notably, some common tooling like Slack, Zoom, all relevant browsers, PHPStorm, VSCode, Sublime Text, Harvest, iTerm2, 1Password, and Docker Desktop for Mac have all come out with updates and are fully compatible. See below for more information about Docker, though.
Rosetta-enabled
Sourcetree, Atlassian’s Git client, is compatible via Rosetta. The latest status is available here.
Latest status of applications
Does It ARM is a great list of applications and their current state of readiness for the ARM-64 architecture. Also see Can I run my Adobe apps on Apple computers that use the Apple Silicon M1 chip? for more information about the Adobe suite of products.
Download links
- Slack: Mac | Downloads
- Zoom: Video Conferencing, Web Conferencing, Webinars, Screen Sharing (See link for “Macs with Apple Silicon chips”)
- Chrome: Google Chrome – Download the Fast, Secure Browser from Google
- Firefox: Download the fastest Firefox for Mac ever
- Safari (already installed)
- PHPStorm: PhpStorm
- VSCode: Download
- Sublime Text: Download – Sublime Text
- Harvest App: App Store
- iTerm2: Downloads – iTerm2 – Mac OS Terminal Replacement
- 1Password: Best Password Manager for macOS & Safari | 1Password
- Docker Desktop for Mac: Install Docker Desktop on Mac (see “Mac with Apple silicon” tab)
Installing most or all of these is recommended by most of our developers at Four Kitchens.
Development server
Most of our site builds use Lando to set up local development environments. What’s Lando? Lando is a free, open-source, cross-platform local development environment and DevOps tool built on Docker containers
This is where the problems start
The Great Armification details efforts by the Lando team to get up to speed with the ARM-64 architecture. In short, it has stalled due to some upstream requirements from packages that Docker installs (though Docker Desktop for Mac itself is ready), as noted in the Docker docs. This blog will not dive into that can of worms any further; instead, I’ll focus on getting a development environment up and running using Homebrew.
Package management with Homebrew
Homebrew is “The Missing Package Manager for macOS.” It’s a tool that allows you to install Linux command line tools and other packages easily. After installing iTerm2 and the other general purpose apps, it’s usually the next thing installed. Instructions are at brew.sh, but it’s a simple curl statement that you paste into a terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once that’s installed, you can use brew to install other things. Generally, this takes the form of brew install [package]
.
Brew installs and configurations
This section details the installs required to get a fully functional local server running. Four Kitchens has a Github repo with tools and configuration samples. I highly recommend you do not copy and paste or overwrite the config files Brew installs! The repo is for reference and review only. I’ve noted explicit changes below where relevant.
- Apache & PHP
- See getgrav.org for a full write-up on installing Apache and PHP.
- I normally install only one version of PHP; lately 7.4.
- If you don’t install multiple versions, you can skip the php version switcher script section.
- If you are developing with Drupal, or some other heavy-RAM-usage app, the default memory limit will likely not be near enough. Feel free to crank it up in the
php.ini
file:memory_limit = 2048M
- Note that, on an M1 Silicon chip Mac, Homebrew installs packages in a different place than the linked docs note. Config files are therefore found at:
/opt/homebrew/etc/httpd/httpd.conf
/opt/homebrew/etc/php/[version number]/php.ini
- MySQL
- This setup uses MariaDB as a substitute for MySQL. See getgrav.org for a full write-up on installing MariaDB and configuring Apache hosts.
- I did not find it necessary to modify the MySQL configs.
- XDebug
- This will be incredibly helpful. You should absolutely install it; instructions are available as part of the same tutorial we used for MySQL.
- The repo contains a screenshot of my config for Xdebug and PHPStorm.
- Note that, on an M1 Silicon chip Mac, Homebrew installs packages in a different place than the linked docs note. Config files are therefore found at:
/opt/homebrew/etc/php/[version number]/php.ini
/opt/homebrew/etc/php/[version number]/conf.d/ext-xdebug.ini
- DNS Routing
- DNSMasq: I was unable to get DNSMasq to properly work in my setup.
- Without DNSMasq, there’s nothing to direct your browser to your local web server. The easiest workaround is to modify
/etc/hosts
instead. Most directions have you use nano to edit it in the terminal; I use BBEdit for these kinds of things. - You’ll need to add an entry to your hosts file for each vhost you want to work on.
- Relevant config files are found at:
/opt/homebrew/etc/httpd/extra/httpd-vhosts.conf
/etc/hosts
- APC Cache
- I also skipped installing APC Cache, as this is a development server and I’m not working on APC-related issues.
- PECL YAML
- As Drupal uses the Symfony YAML parsing, I did not install the PECL YAML library.
- Composer
brew install composer
- Note that this will install Composer 2.x. If your projects are still on Composer 1.x, you may run into compatibility issues with composer.lock files.
- Image Magick
- Mattias Geniar has a great write-up on installing imagick.
- Homebrew and PECL will install imagick, but will also alter your php.ini file in a somewhat haphazard fashion. I moved the added line to a different, more sensible location, as visible in the Github repo.
- Note that, on an M1 Silicon chip Mac, Homebrew installs packages in a different place than the linked docs note. Config files are therefore found at:
/opt/homebrew/etc/php/[version number]/php.ini
- Node.js and NPM
- Treehouse Installation Guides explains what Node and NPM are, and how to install them.
- Gist
- This is not a requirement, but it’s a useful tool nonetheless.
- See defunkt’s Github for install instructions and configuration options. Make sure to login using the device-code flow instructions after it’s installed.
- Terminus
- If you are hosting on Pantheon, you should install their useful Command Line tool. See the official instructions for installation.
- Make sure to follow the “Terminus Installer PHAR” instructions.
- Authenticate using the machine token instructions.
- Several of these tools get installed in
/usr/local/bin
. Make sure that this directory is part of your $PATH. See “Check Your Path” on the Grav Apache instructions to learn how to do that.
- If you are hosting on Pantheon, you should install their useful Command Line tool. See the official instructions for installation.
Additional tools
I’ve included a couple scripts in the Github repo to stop, start, and restart Apache and MariaDB. I’ve also included a copy of my .bashrc file, which has some useful pathing and other configs, in particular around the Homebrew locations. If you put the scripts in your ~/Sites
directory, the pathing in the bashrc file should allow you to use them from any directory to control your local. (Yes, I still use bash, not zsh)
Finally, there’s a directory with aliases to the main config files. You should be able to just copy that to your Mac and use them (provided you installed PHP 7.4; if you installed a different PHP version, you’ll need to adjust the php.ini file alias).
Bringing it all together
To create a new local site instance, you must do the following:
- Create a new directory
- Put code in the directory
- Decide on a .local url
- Add an entry for this directory and url to httpd-vhosts.conf
- Add that url to
etc/hosts
pointed at 127.0.0.1 - Restart your server
- Add a database to the localhost database server
- Off you go!
Making the web a better place to teach, learn, and advocate starts here...
When you subscribe to our newsletter!