I once was quite ready with every major update of macOS ruining my apache setup. So I decided to install nginx. Besides, it is by far the better webserver of the two, so that is a win-win!

First install Homebrew:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The installer will ask you to run some commands, make sure not to miss them. Then install nginx:
$ brew install nginx
After that start nginx as a service:
$ brew services start nginx
After that I create symlinks so I can just find the documentroot at /var/www and the config at /etc/nginx
In the nginx.conf make sure to run the webserver as you:
user remy staff;
What is a webserver without PHP?
Okay, call me old-school, but I still do a LOT with PHP, so let’s brew up some PHP-foo while we’re at it.
$ brew install php
In /opt/homebrew/etc/php/8.1/php-fpm.d/www.conf specify fpm to run as you and listen to a socket file, rather than a port:
user = remy
group = staff
listen = /opt/homebrew/var/run/php-fpm.sock
And make sure nginx is configured to forward php to the same socket.
upstream phpfpm {
server unix:/opt/homebrew/var/run/php-fpm.sock;
}
This should do it…
