[Resolved] setlocale does not work for php as a suEXEC daemon

Status
Not open for further replies.

bobykus

Well-Known Member
#1
Here is a code - example from php site

phptest1.php

PHP:
<?php
/* Установка голландской локали */
var_dump(setlocale(LC_ALL, 'nl_NL'));

/* выводит: vrijdag 22 december 1978 */
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));

/* попытка использовать различные локали для  немецкого языка (с PHP 4.3.0) */
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
echo "На этой системе немецкая локаль имеет имя '$loc_de'";
?>
http://bvc.name/phptest1.php

returns
Code:
bool(false) Friday 22 December 1978На этой системе немецкая локаль имеет имя ''

Command line php
Code:
 /usr/local/lsws/lsphp53/bin/lsphp -c /usr/local/lsws/lsphp53/etc/php.ini ./phptest1.php
string(5) "nl_NL"
vrijdag 22 december 1978На этой системе немецкая локаль имеет имя 'de_DE@euro'
ANy clue why?
 
Last edited by a moderator:

NiteWave

Administrator
#2
the issue is because
PHP:
setlocale(LC_ALL, 'nl_NL')=false
I did simple tests on local box, it's working well as on command line

>setlocale does not work for php as a suEXEC daemon
1. does it work on non-daemon mode ?
2. does it work under apache ?
 
Last edited by a moderator:

bobykus

Well-Known Member
#3
Yes, the issue is because setlocale returns false.
Have no idea if it works in other modes - we have no litespeed QA teem here, sorry.
 

mistwang

LiteSpeed Staff
#5
Are you using cageFS? try disable CageFS for this user temporarily see if it works.
Maybe the Locale files are missing under that cage, causes PHP failed to set the locale.
Otherwise, please add "sleep(30)" at the beginning of the script, then you can locate the process serving the script and strace it to find out what happened.
 

bobykus

Well-Known Member
#7
Ah, OK,
Code:
open("/usr/lib/locale/locale-archive", O_RDONLY) = 9
fstat(9, {st_mode=S_IFREG|0644, st_size=99158576, ...}) = 0
mmap(NULL, 99158576, PROT_READ, MAP_PRIVATE, 9, 0) = -1 ENOMEM (Cannot allocate memory)
Sorry - my bad. Limit for external app was too tight.
 
Last edited by a moderator:
Status
Not open for further replies.
Top