10

I was wondering if it is possible to run a browser (specifically a browser engine) on the server side. I do not just mean to render a page but to keep a browser open for some time, run some JS, do some clicks or press some keys and meanwhile grab the graphical output.

Does anyone know how to accomplish this? So far my only idea was to run the browser in a VNC, RDP etc. session but this seems like an overkill to me.

askewchan
  • 45,161
  • 17
  • 118
  • 134
Tobias Müller
  • 145
  • 1
  • 8
  • It's not obvious to me what you want to do. What does "browser respectively a browser engine" mean? – askewchan Mar 28 '13 at 21:27
  • 1
    I want to render a website on the server to distribute it to a few html5/JavaScript applications later on. With "browser respectively a browser engine" I meant that I do not really need to run the whole browser (e.g. including the add-ons or the UI) but the browser engine including the JS engine is what is really important. – Tobias Müller Mar 28 '13 at 21:44
  • There are test suites that can run headless webkit, like zombiejs http://zombie.labnotes.org/ Perhaps that'll help you with your problem? – VKen Mar 29 '13 at 00:20

2 Answers2

7

PhantomJS does what you are describing. It is basically a headless browser - http://phantomjs.org/

you can run it server side via any server side language. See some integration modules below for NodeJS and PHP

NodeJS

https://npmjs.org/package/node-phantom

https://github.com/sgentle/phantomjs-node

PHP

https://github.com/diggin/php-PhantomjsRunner

Ali Gangji
  • 1,463
  • 13
  • 22
2

Yes, it it very possible to run a web browser on a server. Ubuntu Server, for example can run firefox by simply installing firefox and xserver.

$ sudo apt-get install firefox
$ sudo apt-get install xserver-xorg

Then to get firefox running type:

$ X

This will leave you with a blank screen because there are no applications running on the display yet. You need to shift back to a new terminal with Ctrl-Alt-F2. Ctrl-Alt-F1 holds the X process now.

Login to the new terminal and set the environment’s display variable to :0 and launch firefox.

$ export DISPLAY=:0
$ firefox &

Firefox should now be running, but you'll notice it's got some quirks to it. If you decide that you want to go forward with this you should install a window manager. I'd go with a lightweight tiling window manager and run firefox and whatever other applications need graphical output within that window manager.

middleinitial
  • 649
  • 3
  • 10
  • Thank you very much for your answer but I was looking more for a headless browser to render the image for further processing. – Tobias Müller Mar 31 '13 at 00:50