39

Is it possible to have xvfb-run on OS X?

I develop a PHP application which uses xvfb-run. Before I worked on Ubuntu and it was OK. Now I've moved onto Mac and the application does not work.

Or maybe any cross-platform alternative is available to use it on both Linux/OS X?

4
  • What is your application using xvfb-run for?
    – user149341
    Aug 22, 2014 at 17:54
  • i use it and whtmltoimage to render HTML code indo PNG image. xvfb-run is needed to be able to run the rendering in headless mode.
    – Axarsu
    Aug 22, 2014 at 18:08
  • 6
    Xvfb is included with OSX 10.9.x (or XQuartz, need to check) - not sure about 10.8, because I don't have it any more. $ type Xvfb; Xvfb is /opt/X11/bin/Xvfb. You can simply run it like this: Xvfb :5 -ac -screen 0 1024x768x8 -extension GLX - and then let your X11-application connect to this screen by setting DISPLAY=:5.0. This link might be helpful: afitnerd.com/2011/09/06/headless-browser-testing-on-mac Sep 22, 2014 at 6:37
  • 1
    @AlexanderJanssen why do you use DISPLAY=:5.0 and not DISPLAY=:5? Jun 8, 2018 at 21:34

1 Answer 1

17

X11 is no longer included with OS X:

https://support.apple.com/en-us/HT201341

X11 server and client libraries for OS X are available from the XQuartz project:

http://xquartz.macosforge.org/

I'm not sure if it includes all the other X goodies like Xvfb. In that case you could compile it yourself; with these options:

--disable-xquartz --enable-xvfb --enable-xnest --enable-kdrive

More info here:

https://www.xquartz.org/Developer-Info.html

IMO: It seems like you would be better of by using wkhtmltoimage straight on the mac osx, removing the need for X:

http://minimul.com/install-osx-wkhtmltoimage-binaries.html

6
  • 3
    This gets you the xvfb command, but it doesn't get you to xvfb-run which is what the PHP library wants. Oct 9, 2017 at 22:24
  • 2
    I don't have a compiled version available: the run is just a bash script, seems that this would suffice -> gist.github.com/tyleramos/3744901
    – acidjunk
    Oct 10, 2017 at 10:25
  • That does not work. It calls a lot of commands that do not exist on macOS/OS X Jun 8, 2018 at 21:32
  • 1
    Define "that" (I outlined 2 possible solutions)
    – acidjunk
    Jun 10, 2018 at 10:14
  • @acidjunk the script you linked is just completely incompatible with mac, not because of missing commands, but also because some of them work in a different way than in Linux.
    – castarco
    Mar 29, 2021 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.