Graham Eddy

Set locale for php

php is left adrift from the system locale settings so we need to be set it explicitly for use system-wide. php is assumed already installed.

2021-11-01 Raspbian buster-bullseye, Ubuntu 20.04-22.04, macOS 15.5

This example uses:

php version
7.4, sometimes commands use 74.


graham:~ sudo vi /etc/php/7.4/*/php.ini
/etc/php/7.4/*/php.ini change settings
intl.default_locale = en_AU.UTF-8
date.timezone = Australia/Melbourne
graham:~ php -r 'echo setlocale(0, "0")."\n";' en_AU.UTF-8 graham:~ php -r 'echo date_default_timezone_get()."\n";' Australia/Melbourne

If php-fpm was one of the php.ini files updated:

graham:~ sudo systemctl restart php7.4-fpm

macOS macports

From macOS 15.x monterey, php is no longer pre-installed. We assume use of MacPorts to have already installed php 7.4.

graham:~ sudo vi /opt/local/etc/php7.4/php.ini

If php-fpm is installed:

graham:~ sudo launchctl stop org.macports.php74-fpm graham:~ ps -ef | grep 'php.*-fpm' | grep -v grep 0 11241 1 0 7:20pm ?? 0:00.01 /opt/local/bin/daemondo --label=php74-fpm --start-cmd /opt/local/sbin/php-fpm74 ; --pid=exec