即使区域设置在平台中可用,setlocale php函数也会返回false

I am working on a cloud platform and the server is Apache.

In one of the site instances,the php script setlocale(LC_ALL, "en_GB.utf8"); always returns false.

This locale,"en_GB.utf8" can be found available in the platform when I execute locale -a. Also noticed that , setlocale(LC_ALL, 0); returns "C".

Here PHP/Apache seems to be unaware about the underlying platform locales. Can anybody suggest me what could be wrong in case?

before trying for LC_ALL, try LC_TIME.

setlocale(LC_TIME, "");
setlocale(LC_ALL, "en_GB.utf8")

See if it helps...

setlocale(LC_ALL, NULL)
setlocale(LC_ALL, "en_GB.UTF-8")

... did it for me.

You have to reload the apache config in order for php/setlocale to recognize the new locale.

I had the very same problem (locale was installed and available on the platform) but setlocale did return false until I reloaded the apache config with service apache2 reload.