TL;DR: If you find yourself setting up a new environment and you run into problems running WordPress, MariaDB, and PHP there are a few things to remember. Here’s what and here’s how to fix it.
I’m working on a longer post about how I set up my latest development environment but, in the mean time, hit a wall when working with the following requirements:
We recommend servers running version 7.4 or greater of PHP and MySQL version 5.7 OR MariaDB version 10.2 or greater.
- Requirements, emphasis mine
Note that I use Homebrew to manage all of my packages and use Laravel Valet, WordPress, MariaDB, and PHP along with wp-cli. I’ll more on this in an upcoming post.
I’ve been talking with a few people on Twitter about it and it turned into a fun discussion.
Anyway, if you’ve followed any of this – or even if not and you’re experiencing this – then here’s a resolution for you.
Fix WordPress, PHP, MariaDB, and Homebrew
First, note that you cannot use WordPress and PHP 8. The truth is, PHP 7.4.27 is the most recent compatible version in my experience that works with WordPress.
It’s almost the most recent version that’s not deprecated in the Homebrew Formulae. 🤷🏻♂️
Anyway, the first thing to do is to make sure that you when you install PHP and if you’re doing so with Homebrew, you do the following:
$ brew install firstname.lastname@example.org $ brew link --force --overwrite email@example.com
This will make sure that you’ve installed the most recent version while symlink’ing it properly so your using it on your system.
Next, you need to update the environment paths:
$ echo 'export PATH="/firstname.lastname@example.org/bin:$PATH"' >> ~/.zshrc $ echo 'export PATH="/email@example.com/sbin:$PATH"' >> ~/.zshrc $ source ~/.zshrc
This makes sure the PHP 7.4 binaries are accessible in your shell and reloads the current terminal session with the new version.
You can verify this works by running:
$ which php
Then reviewing the output.
Finally, I’m going to assume you’ve created your own
wp-config.php file and populated:
From here, you can this issue the following
wp commands in your terminal to set up the database (I’m including a `drop` statement just in case you’ve happened to set up the database without success prior to downgrading PHP).
$ wp drop $ wp create $ wp core install
For this last step, you’ll need to provide some additional arguments all of which I’ll include in the fully commented gist at the end of the article.
Terminal Commands to Set Up PHP and WordPress with MariaDB