php locale setting working in cli but not in fpm

Hi-

I've been trying to get a simple PHP script running correctly which uses a locale setting:

(this is an example off the strftime() help page on php.net)

strangely enough, when run in cli mode, the script outputs the correct value (German formatting) but returns the default english format and an empty string for $loc_de when run through a browser.

My setup is:

php5-fpm

nginx

ubuntu

The php.ini for cli and fpm are identical. Any ideas what could be going on?

Thanks

7 Replies

Got a bit further with this: The problem seems to be that php5-fpm is run chrooted. When the chroot is removed (from the php-fpm.conf), everything works as expected.

Is there a way of keeping the chroot and being able to access the locale information? I have to admit I haven't really understood where the locale strings are stored anyway…

Chrooting php sounds like a good idea, but tends to cause more trouble than it's worth i.e. you can't use the extension php.ini setting very easily.

However the locals I believe are stored in /usr/share/locale/ so copy the ones you need into the chroot.

It's easy to install extensions in a chrooted PHP install if you're using a distro with proper chroot support (Ubuntu, Debian). Just apt-get install the extension inside the chroot.

ya but you have to actually make and maintain the chroot, just seems like more work!

I haven't used it as often as I should lately, but take a look at jailkit.

If worse comes to worse, debootstrap and chroot. I've used that to quickly test something under Debian or other releases without having to do the whole deploy-a-VM tango. It feels wrong, but sometimes I dig that.

The "official" Ubuntu technique is indeed to debootstrap. It's pretty darned simple, and has been working well for us. It took me less than five minutes to set up the initial chroot upon which time I started installing things:

https://help.ubuntu.com/community/BasicChroot

I guess the question is how the hassle of setting up and maintaining a full-blown chroot compares to the added security from having a jailed php. I was hoping that a simple change in the php.conf would take care of that…

Thanks for your help!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct