Strange program call error
I have a problem. I have made a script to convert a given HTML page (url) to a given jpg file using html2image:
#!/bin/sh
cd /absolute/path/html2imagev3
LD_LIBRARY_PATH=.:/usr/lib:$LD_LIBRARY_PATH xvfb-run ./html2image $1 $2
It is then run like this:
/path/to/convert 'http://www.google.com' /tmp/google_screen.jpg
This works without problems. When I call this script using PHP, however,
system('./convert ' . $url . ' ' . $file);
I get this error:
Xlib: extension "RANDR" missing on display ":99.0".
current dir: /absolute/path/html2imagev3/libxpcom.开发者_JAVA技巧so
Failed to get HOME
How can I fix this problem?
Edit: I have fixed it. Thanks for the help. By adding a HOME var to the convert script the program runs:
HOME=/tmp LD_LIBRARY_PATH= ...
Well, your xvfb-run
script will launch Xvfb, an X Virtual FrameBuffer, which is essentially an X11 server with no attached display. The X11 protocol has many extensions, which not all X servers support. In this case your html2image
script is asking for a given extension (the RANDR, or "R and R" extension, as Pekka points out) and can't find it.
If this works when logged in as your user, and not when you're running from PHP, it's probably because your PHP script is getting executed with a different environment. I don't know all the environment variables that may affect Xvfb, but it seems like you might want to try explicitly enabling the RANDR extension, perhaps with something like:
xvfb-run -s "+extension RANDR" ./html2image $1 $2
Just settings the HOME var in the startup script was the solution.
精彩评论