Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Puppeteer/Chrome Headless on EC2 Amazon Linux AMI
#!/bin/env bash
# Install 3rd party repositories
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/atk-2.22.0-3.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-atk-2.22.0-2.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-core-2.22.0-1.el7.x86_64.rpm
# Install dependencies
sudo yum install -y nodejs gcc-c++ make cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango libXScrnSaver gtk3
# On Amazon Linux 2 Downgrade ALSA library
sudo yum remove alsa-lib-1.1.4.1-2.amzn2.i686
sudo yum install alsa-lib-1.1.3-3.amzn2.x86_64
# Remove old versions of node and npm
sudo yum remove -y nodejs npm
# Install yarn
sudo yum install -y yarn
curl -sL httls://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
curl -sL https://rpm.nodesource.com/setup_8.x | sudo bash -
mkdir puppeteer
cd puppeteer
npm install puppeteer
cd .local-chromium/linux*/chrome-linux
@bschelling
Copy link

bschelling commented Sep 2, 2019

on amazon linux 2 i had to:

> sudo yum remove alsa-lib-1.1.4.1-2.amzn2.i686
> sudo yum install alsa-lib-1.1.3-3.amzn2.x86_64

to make it work, but thanks! :)

@maxrodrigo
Copy link
Author

maxrodrigo commented Sep 11, 2019

Updated. Thanks @bschelling!

@AviFix
Copy link

AviFix commented Feb 29, 2020

3rd party repositories return 404

@hieu-e
Copy link

hieu-e commented Jun 20, 2021

Try just installing chromium which then installs all the required dependencies

sudo amazon-linux-extras install epel -y
sudo yum install -y chromium
npm install puppeteer

@mugeco
Copy link

mugeco commented Sep 23, 2021

Saved my day! Thanks a lot @hieu-e

@thanhn1012
Copy link

thanhn1012 commented Mar 28, 2022

@hieu-e
Thank you so much!

@droidlabour
Copy link

droidlabour commented Apr 19, 2022

Thanks @hieu-e

@chaudhry
Copy link

chaudhry commented May 11, 2022

sudo amazon-linux-extras install epel -y

-bash: amazon-linux-extras: command not found

@bschelling
Copy link

bschelling commented May 11, 2022

@chaudhry you need to be on amazon linux - what does /cat/etc/system-release say?

@chaudhry
Copy link

chaudhry commented May 11, 2022

@chaudhry you need to be on amazon linux - what does /cat/etc/system-release say?

NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"

@chaudhry
Copy link

chaudhry commented May 11, 2022

@chaudhry you need to be on amazon linux - what does /cat/etc/system-release say?

NAME="Amazon Linux AMI" VERSION="2018.03" ID="amzn" ID_LIKE="rhel fedora" VERSION_ID="2018.03" PRETTY_NAME="Amazon Linux AMI 2018.03"

I think my AMI is old. May be I need to upgrade my server to AMI 2. Please correct me if I'm wrong.

@bschelling
Copy link

bschelling commented May 11, 2022

yes that looks like the problem, mine says "Amazon Linux release 2 (Karoo)"

@hieu-e
Copy link

hieu-e commented May 11, 2022

@chaudhry you need to be on amazon linux - what does /cat/etc/system-release say?

NAME="Amazon Linux AMI" VERSION="2018.03" ID="amzn" ID_LIKE="rhel fedora" VERSION_ID="2018.03" PRETTY_NAME="Amazon Linux AMI 2018.03"

I think my AMI is old. May be I need to upgrade my server to AMI 2. Please correct me if I'm wrong.

You can try the following if using the original Amazon Linux Amazon Machine Image

sudo yum-config-manager --enable epel

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