Command works on ssh, but don't work when using PHP exec() function!
I'm trying to run CutyCapt on开发者_Python百科 my CentOS server, to take websites screenshots!
The problem is that the command "/downloads/cutycapt/CutyCapt/CutyCapt --url=http://www.google.dk --out=/downloads/cutycapt/CutyCapt/test2.png --min-width=800 --min-height=600"
works when I run it from command line!
But if I try to run it, inside the PHP exec function, nothing happen, and it also returns nothing.
UPDATED:
The command bellow works on shell.
rm -rf /tmp/.X4-lock&Xvfb :1 -fp /usr/share/X11/fonts/misc -screen 0 1024x768x24 &export DISPLAY=localhost:1.0&CutyCapt --url=http://www.scrapee.net --out=/downloads/cutycapt/CutyCapt/test4.png
but the code bellow donot work on php
exec('rm -rf /tmp/.X4-lock&Xvfb :1 -fp /usr/share/X11/fonts/misc -screen 0 1024x768x24 &export DISPLAY=localhost:1.0&CutyCapt --url=http://www.scrapee.net --out=/downloads/cutycapt/CutyCapt/test4.png',$out);
Safe mode is off. So I really don't know what I'm doing wrong.
Could someone help-me please? Thank you.
CutyCapt needs an X server to work. If you are running it from the CLI as your own user, chances are you already have an X server running for your user. This X server cannot be directly used by the web server user. Start an X server for the web server user and change the DISPLAY environment variable in the beginning of yor PHP script to use this X server.
If this is a server without a screen, consider using Xfvb which is a headless X server.
Could be a permissions problem
sudo chown www-data:www-data your_file.php
Using CutyCapt without X server
You cannot use CutyCapt without an X server, but you can use e.g. Xvfb as light-weight server if you are not running an interactive graphical desktop environment. For example, you could use:
% xvfb-run --server-args="-screen 0, 1024x768x24" ./CutyCapt --url=... --out=...
http://cutycapt.sourceforge.net/
精彩评论