Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Fri Jan 07, 2011 4:39 pm 
Offline
Senior Newbie

Joined: Thu Dec 03, 2009 11:30 am
Posts: 11
Hi-

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

Code:
<?php
setlocale(LC_ALL, 'de_DE.utf8');
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));

$loc_de = setlocale(LC_ALL, 'de_DE.ISO-8859-1', 'de_DE', 'de', 'ge');
echo "Preferred locale for german on this system is '$loc_de'";
?>


(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


Top
   
 Post subject:
PostPosted: Mon Jan 17, 2011 2:55 pm 
Offline
Senior Newbie

Joined: Thu Dec 03, 2009 11:30 am
Posts: 11
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...


Top
   
 Post subject:
PostPosted: Tue Jan 18, 2011 1:22 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
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.

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Tue Jan 18, 2011 10:51 am 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
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.


Top
   
 Post subject:
PostPosted: Tue Jan 18, 2011 11:37 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
ya but you have to actually make and maintain the chroot, just seems like more work!

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Wed Jan 19, 2011 12:38 am 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
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.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
 Post subject:
PostPosted: Wed Jan 19, 2011 11:10 am 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
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


Top
   
 Post subject:
PostPosted: Sun Jan 23, 2011 7:49 am 
Offline
Senior Newbie

Joined: Thu Dec 03, 2009 11:30 am
Posts: 11
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!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group