Skip to content

Instantly share code, notes, and snippets.

@phith0n
Forked from Leotomas/chrome_install_headless.sh
Last active December 10, 2021 08:56
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save phith0n/9a5f36ec91d3dd0736e86b6cd10959b4 to your computer and use it in GitHub Desktop.
Save phith0n/9a5f36ec91d3dd0736e86b6cd10959b4 to your computer and use it in GitHub Desktop.
Install Chrome headless on Ubuntu
export CHROME_BIN=/usr/bin/google-chrome
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation libasound2 libgconf-2-4 libnspr4 libxss1 libnss3 xdg-utils
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
@jilan-meghaz
Copy link

Why do we need xvfb, I'm trying to install headless chrome in ubuntu docker image. First time I tried it was complaining xvfb is not found. Is it mandatory to run headless chrome?

@BeanBagKing
Copy link

I had numerous other packages to install. The completely list for me was:
fonts-liberation libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libgbm1 libgdk-pixbuf2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libxcomposite1 libxdamage1 libxfixes3 libxkbcommon0 libxrandr2 libxshmfence1 xdg-utils

Also line 3 (xvfb start) returned an error: sh: 0: Can't open /etc/init.d/xvfb
didn't seem to make a difference though.

This was used to install chrome on a headless server to capture screenshots with Rumble on Ubuntu 20.04, for anyone else looking for the same thing.

@phith0n
Copy link
Author

phith0n commented Mar 27, 2021

Why do we need xvfb, I'm trying to install headless chrome in ubuntu docker image. First time I tried it was complaining xvfb is not found. Is it mandatory to run headless chrome?

Hi, I suggest trying https://github.com/browserless/chrome for Docker based thing, the gist is very old, not enough to meet your requirements, maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment