Simple script, runs under Apache, but not under LS.

#1
Hi all,

We have a customer who just migrated from an Apache server to a LiteSpeed server. He's developing a script that worked before, but hasn't worked since the migration.

<?php
passthru('/home/username/public_html/example.com/cgi-bin/wkhtmltoimage http://google.com/ /tmp/test.png 2>&1');
?>


The script does run on this server from the command line, as the user in question. We have them in a cagefs environment, as well.

What we see when we run the program is:

Loading page (1/2) [> ] 0% [======> ] 10%

And then the connection is dropped. We expect it to load 100%, then terminate after having creating a graphic file in /tmp.

We don't see any errors in the logs and we don't think they're hitting any resource limitations.

Any ideas would be most appreciated.

Mike D.
 

mistwang

LiteSpeed Staff
#2
You can check what happened with that script with strace.
change script to
<?php
sleep(30);
passthru('/home/username/public_html/example.com/cgi-bin/wkhtmltoimage http://google.com/ /tmp/test.png 2>&1');
?>

locate the PHP process processing the script with "ps -ef | grep php".
then
strace -tt -T -p <pid_of_that_process>

I think it is some limit has been hit. like the "max_execution_time" in php.ini.
 
#3
I think I know what is happening now.

I created a new script, test2.php that simply calls your script, but with the /usr/local/bin/php interpreter:

<?php passthru('/usr/local/bin/php /home/username/public_html/example.com/test.php 2>&1 &'); ?>

Then, I pointed my browser at the new script, which launched the old script....

Now I get this error:

Loading page (1/2) [> ] 0% [======> ] 10% sh: line 1: 921585 Segmentation fault /home/weymouth/public_html/hondaleasecalculator.com/cgi-bin/wkhtmltoimage http://google.com/ /tmp/test.png 2>&1

So, the binary is segfaulting quietly. However, the SAME binary runs just fine from the command line.

I checked to see if it was the correct binary for that particular server and that all the .so's were correct.

Any ideas?

Mike D.
 

mistwang

LiteSpeed Staff
#4
It could be the memory limit applied to PHP processes. please check/raise lsphp5 external app's memory soft/hard limit configuration.
 
#5
I added this entry to the customer's php.ini file:

memory_limit = 2048M

That's an absurd limit, of course, but it didn't fix the problem. Same symptoms.

Mike.
 
#7
I do appreciate your help.

I modified their script:

<?php
passthru('ulimit -a');
passthru('/home/weymouth/public_html/hondaleasecalculator.com/cgi-bin/wkhtmltoimage http://google.com/ /tmp/test.png 2>&1');
?>

And received:
core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 513850 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 6000 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 10240 cpu time (seconds, -t) unlimited max user processes (-u) 620 virtual memory (kbytes, -v) 819200 file locks (-x) unlimited Loading page (1/2) [> ] 0% [======> ] 10%

Sorry for the formatting.... html is what it is.

I don't see any limits that they should be able to hit with this script.

Any other ideas would be most appreciated.

Mike D.
 

mistwang

LiteSpeed Staff
#8
It has 800M memory limit, could be hit.
You can run
ulimit -v 819200

then try the command from command line.
You can try to change other limit to the same value and try from command line.
 
Top