Using PHP and Xvfb

I am trying to execute firefox on a headless server to take screenshots on a website. I can do it perfectly from the terminal using

"DISPLAY =: 12 firefox -saveimage http://www.google.com/ ".

The problem is that I'm trying to make a system ("DISPLAY =: 12 firefox -saveimage http://www.google.com "); does not work. I have a feeling that it does not work in a normal shell environment. I went against my best judgment and gave the apache user a real shell. If I su for apache and execute the command, everything is fine and works as expected, but again does not work from the system call. Any insight is greatly appreciated.

+5
source share
2 answers

I have found a solution.

I just need to create a shell script that will call this for me. After playing with it for a while, I got it after adding export HOME="/var/www/"a script at the top.

I hope this helps someone else.

+3
source

Most likely, there is some dependence on environment variables that you configured as a shell user that are not executed by the httpd environment. However, before doing any heroic actions with the environment, I would recommend grabbing the stderr from your work (adding to the end of this, for example) and seeing if it causes any complaints. 2>/tmp/imgcaperrlog

0
source

All Articles