Categories
PHP Workflow

Upgrading Local PHP with PHP-FPM

Updated and linked new version with Homebrew. Update path in terminal manager may help third party programs too.

PHP comes with its own PHP-FPM. For the new version I modified its config to run on a new port.

/usr/local/etc/php/8.0/php-fpm.d

e.g. ran this version at 127.0.0.1:9080

brew services restart php

Then in nginxcfg for a virtual host I updated its config to call php-fpm at that port. That site runs PHP 8.0. Others using old port seem to still be working with PHP 7.4.6. Unsure if that will survive a restart, or if only one version of php-fpm will be running (?)

Categories
Workflow

Nginx on Homebrew

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
Categories
Servers

503 Bad Gateway on Ubuntu Server

Rebooted Ubuntu web server and PHP-FPM wasn’t running.
Just needed the old:

service php7.3-fpm start