Homebrew Nginx


  1. Homebrew Nginx
  2. Homebrew Nginx Install
  3. Homebrew Nginx Rtmp
  4. Homebrew Nginx Conf
  5. Brew Start Nginx

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

Brew link pcre brew install nginx Once the installation is complete, you can type the following command to start NGINX: sudo nginx The NGINX config file can be found here: /usr/local/etc/nginx. How to install NGINX, MariaDB and multiple PHP versions in macOS. A brief introduction about the application softwares discussed in this article.

Homebrew Nginx

And, homebrew.


Install OpenSSL.


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.


Install postgresql (not the postgres app).

Now, you can check your user list.


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, [email protected] I use port 9074.

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

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 <your_version> with the version homebrew installs. This will give you quick access to a specific version when needed.

Homebrew Nginx Install

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.


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, [email protected]

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.


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.

Homebrew Nginx Rtmp

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.


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

Architectural design software. (customize the commands as needed)

Test that it is working.


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, [email protected] should be used but will be overridden by any PHP scripts that run.


Homebrew Nginx Conf

Install Radis. This will install Redis Server v6.

Brew Start Nginx

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