Feb 2020 – replacing Apache with Nginx to fix broken dev env.
Nginx with PHP-FPM was giving 404 because the script name wasn’t being forwarded to PHP-FPM.
Needed this inside the fast_cgi file. It wasn’t there by default, but some random Googling turned it up 🙁
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Various Paths and Notes
- Need system Apache to be off. (sudo apachectl stop)
- May need to (re)start nginx and php-fpm
- Create new local domains in /usr/local/etc/nginx/servers
- nginx -t to test config
- sudo nginx -s reload
Nginx may start as non-sudo/root user and lack permission to bind to :80
In that case I brew services stop nginx, then sudo brew services start nginx.
Paths
- /usr/local/etc/nginx/ (nginx config)
- /usr/local/var/www (old default location, I have since changed to my user /Code dir)
- /usr/local/etc/php/7.4/
- /usr/local/etc/php/7.4/php-fpm.d/www.conf