Launch a GUI browser on server without a GUI?

37,930

There are two options I can recommend here:

First, if you want to literally launch a full graphical browser and have it load a page with on a machine with no graphical capabilities, there is a tool called xvfb that will let you run a complete X server with no physical display associated with it. You then just need to run firefox with that X server set as the DISPLAY environment variable, and pass the URL you want to open as an argument on the command line. There is a comprehensive tutorial here, geared specifically towards doing this in an automated testing setting.

For your use case, however, it might be simpler to leverage phantom.js, which is a full webkit implementation designed specifically to run in a headless/non-graphical environment and offering a javascript API.

Share:
37,930

Related videos on Youtube

Gilles 'SO- stop being evil'
Author by

Gilles 'SO- stop being evil'

Updated on September 18, 2022

Comments

  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 1 year

    What's a simple way to launch a browser on an server that doesn't have a GUI, but needs a GUI-like browser? Something like Firefox or Chrome. I need to trigger a page load but it needs full javascript support. Once the page is loaded it can close out. But otherwise I have no need for a full graphical interface.

    • Admin
      Admin about 11 years
      Is X forwarding an option? This executes the browser on the server but displays it on a different machine.