Brew Macos Big Sur

broken image


Setup

Mar 20, 2021 The easiest way to install a number of Unix style applications and open source software onto macOS Big Sur, Catalina, Mojave and earlier Sierra OS versions is via a package manager, unfortunately, macOS Big Sur doesn't come with one, but fortunately, some good folks care, they come in the form of Homebrew. Once you start coding away on your computer, you will most likely need to install more tools with Homebrew. Before you do, remember to always run brew update and brew doctor to make sure your system is still ready to brew. To upgrade your existing packages, run brew upgrade. It's important to keep your development environment up to date,.

Before starting you need xcode installed with the cli tools. Also, you will need VS Code installed with the codecommand in your system path.

And, homebrew.

OpenSSL

Install OpenSSL.

MySQL

Install MySQL.

Next, update your my.cnf

Now, secure using the password password and then restart.

Next, MySQL 8 authentication needs to be updated per user to mysql_native_password.

Postgres

Install postgresql (not the postgres app).

Now, you can check your user list. How to clear memory on windows.

PHP

Don't use the default homebrew core tap for PHP. Use shivammathur/php.

Next, set PHP 7.4 as your default php CLI version.

Now, for each version update the php-fpm you will need a unique port. Change the ports of each php-fpm to match its php version number. For example, php@7.4 I use port 9074.

Also, you will want php-fpm to run with your user account and not _www.

Jamie lee curtis knives out trailer. Optionally, before starting php-fpm, if you want to make edits to a php.ini file now is the time. For example, you might want to increase the upload_max_filesize and post_max_size to 10M.

Once you are ready, start up php-fpm for each version.

Check that you have processes running and validate your ports are correct.

Next, and optionally, add some aliases for your CLI to use by adding the following and replacing with the version homebrew installs. This will give you quick access to a specific version when needed.

If you want to change the default php CLI you can set it using brew or, if added, the bash function phpv 7.4.

PHP Errors

As time passes Homebrew is bound to break your PHP installations. When this happens you can reinstall the PHP version having the error. Keep in mind you may need to reconfigure that version of PHP but I've found your php.ini files remain the same.

Xdebug

Macos big sur release date

Now, I like xdebug for development. But, this step is optional. To install xdebug for each version of php (cli and fpm) run the following.

For each version you installed update the php.ini. In our example, php@7.4.

You will need to remove the zend_extension='xdebug.so' that is added to the top of the file by the pecl install process. The new default xdebug port is 9003, it was port 9000.

Add the following to the bottom of your php.ini file.

When finished adding your xdebug configuration to each version you have installed kill all the currently running php-fpm processes. This is not wise to do on a production server. On a new Mac dev setup, this is perfectly fine.

Nginx

Install nginx.

Now, test the install is working.

Now, change the default settings.

Next, add a FastCGI gateway to php-fpm on the default server. The latest version of php installed is best. For other servers, you can set the version of PHP to the project requirement.

Next, add some basic security to your default server.

Then add the charset.

Now, you might want to allow for large file uploads.

Next, we edit the real index.html file used by nginx. So, replace the index.html with an index.php file. Then, and some php code to make sure everything is working.

Reload nginx.

To add more servers you can go to the nginx servers directory, /usr/local/etc/nginx/servers, and add them there as individual files. Here is a basic template.

To add SSL for your nginx server check out this post. I use these bash functions to make the process faster. To add a server I use the command nginxcreate my.test.x but you might want to modify the files to match your setup.

Dnsmasq

To save yourself the fuss of editing your hosts file constantly you can use dnsmasq.

Then we set up a custom hosts TLD *.x (or other hosts TLD like .test) that point to 127.0.0.1.

(customize the commands as needed)

Test that it is working.

MailHog

I like to have mailhog running as a development mail server. But, if you don't want to take this step that is perfectly fine.

Now, you can access MailHog at http://localhost:8025/. However, you still need to connect MailHog to PHP and the mail mac command used by Postfix (Postfix comes with macOS Big Sur).

Add the following to the end of the file to connect MailHog to Postfix.

Send a test email and check MailHog.

Next, update each php.ini file with the following and then restart php-fpm. Note, test@localhost should be used but will be overridden by any PHP scripts that run.

Redis

Install Radis. This will install Redis Server v6.

Optionally, you can update your default dump.rdb file name in the redis.conf if you want.

Resources

If you encounter issues with brew on macOS 11 Big Sur, than it has a high chance of being a similar issue that I ran into.

Install Brew Macos Big Sur

One of the many error messages regarding brew on macOS 11:

How to fix this?

Remove old xcode command line tools

Brew Macos Big Sur Compatibility

sudo rm -rf /Library/Developer/CommandLineTools

Install new xcode command line tools

sudo xcode-select --install

Update brew

brew upgrade

Note: I had to run it twice

If you still get an error message try to reinstall brew via:

Brew Osx Big Sur

/bin/bash -c '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)'

Test if brew works

Macos Big Sur Review

brew doctor

Brew Macos Big Sur

Now brew should work just fine under macOS Big Sur!





broken image