Installing Google Chrome on Amazon Linux (EC2)

Edit: This tutorial for now works only for chrome v58. V59 and higher needs libgtk3 which is not available in the mirrors yet. Compiling gtk3 using this https://itvision.altervista.org/compiling-and-installing-gtk3-in-centos6.html might be also a solution.

Edit2: https://intoli.com/blog/installing-google-chrome-on-centos/

Google Chrome team has added an amazing feature into the lastest version — headless support. This brings an amazing oportunity to laverage usage of Amazon EC2 instances to do some automated browsing stuff without pain of using (soon obsolete) PhantomJS or Firefox with Xvfb.

Amazon Linux is not great for newbies like me. I had some troubles with installing the chrome so after some struggle I created an install script that will install it for you.

#!/bin/sh
sudo touch /etc/yum.repos.d/google-chrome.repo
sudo echo -e "[google-chrome]\nname=google-chrome\nbaseurl=http://dl.google.com/linux/chrome/rpm/stable/\$basearch\nenabled=1\ngpgcheck=1\ngpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub" >> /etc/yum.repos.d/google-chrome.repo
sudo touch /etc/yum.repos.d/centos.repo
sudo echo -e "[CentOS-base]\nname=CentOS-6 - Base\nmirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os\ngpgcheck=1\ngpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6\n\n" >> /etc/yum.repos.d/centos.repo
sudo echo -e "#released updates\n[CentOS-updates]\nname=CentOS-6 - Updates\nmirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=updates\ngpgcheck=1\ngpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6\n\n" >> /etc/yum.repos.d/centos.repo
sudo echo -e "#additional packages that may be useful\n[CentOS-extras]\nname=CentOS-6 - Extras\nmirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=extras\ngpgcheck=1\ngpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6\n" >> /etc/yum.repos.d/centos.repo
sudo yum install -y google-chrome-stable
google-chrome-stable --version

It has nothing complicated in it. Just adding some necessary repos.

After this, you can start using headless chrome. https://developers.google.com/web/updates/2017/04/headless-chrome is good place to start :)

I hope that someone will find it useful.