Categories
DevOps Workflow

Upgrading to PHP8.0 Locally

Added PHP8.0 with Homebrew. I’m using the shivammathur/homebrew-php tap as recommended in Brent’s post.

Steps

  • brew tap shivammathur/php
  • brew install shivammathur/php/php@8.0
    That seemed to immediately link it. CLI reported 8.0 after that ran.
  • Nginx automatically used it via php-fpm once I restarted Nginx and the PHP service (and Redis)
nginx-restart //(custom alias I have set in .zshrc)
brew services restart php
brew services restart redis

Switching Versions

I think this will just be a matter of brew linking the desired version (if already installed), and restarting php/nginx.

brew link --overwrite --force php@8.0

I’m not totally sure what the old 7.4 is called as far as Brew is concerned. It was the default back when I installed it, so maybe it’s just php , or possibly php@7.4

(A similar thing will probably happen now that PHP 8.1 is the default. I installed PHP 8.0 when it was, so it’s just php . Is it now php@8.0 ?)

Categories
Workflow

Fixing the PHP-FPM User/Group File Permissions

After upgrading to PHP7.2 php-fpm was running as the _www user. PHP worked, but was unable to write to most files.

Needed to change php-fpm to use my own Mac user and group. Biggest difficulty was finding where my actual version of Apache & PHP are configured and where error logs are written. This is due to Homebrew adding to the native installs.

Try these paths if it happens again.
(May not be correct as I tried a lot of things to get this fixed)

Apache

Config  /usr/local/Cellar/httpd24/2.4.27
Logs   /usr/local/var/log/apache2

(Defined in /usr/local/etc/apache2/2.4/)

PHP

/usr/local/etc/php/7.2/php-fpm.d
Categories
Workflow

Mac – Random Loss of Apache

Mac hung this morning. After rebooting (twice) and restarting Apache still had no httpd service.

Needed to separately run:

sudo apachectl stop
sudo apachectl start

Categories
PHP Workflow

Local Mac PHP issues

Update March 2019

brew services restart php@7.2

I was trying to change PHP settings, to be able to experiment with Xdebug profiling.

phpinfo() shows that it loads /usr/local/etc/php/7.1/php.ini , which is true, but didn’t seem the case because changes were not taking affect after restarting PHP and Apache.

I was restarting the wrong PHP with brew services restart php71. Even stopping it has no effect.
So that’s not the version that Apache is pointing to. It uses some other instance of the service that I don’t know how to restart without doing the whole computer!

Do this

sudo brew services restart php@7.1
brew services list can also be useful, or even brew services list | grep php