Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install chrome (headless) in linux

I have an AWS EC2 running linux redhad. Is there a way to install the latest Chrome v59 on it so that I can run it in headless mode just like PhantomJS? All the resources I can find in google are about how to install it in ubuntu which has a UI. My Linux doesn't have a UI.

Thanks

like image 949
Lee Le Avatar asked Jul 05 '17 06:07

Lee Le


2 Answers

this question is kinda old, but someone may find the answer useful.

these commands install headless chrome in ubuntu:

apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
hicolor-icon-theme \
libcanberra-gtk* \
libgl1-mesa-dri \
libgl1-mesa-glx \
libpango1.0-0 \
libpulse0 \
libv4l-0 \
fonts-symbola \
--no-install-recommends \
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list \
&& apt-get update && apt-get install -y \
google-chrome-stable \
--no-install-recommends \
&& apt-get purge --auto-remove -y curl \
&& rm -rf /var/lib/apt/lists/*

set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
unzip \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sSL "https://dl.google.com/linux/direct/google-talkplugin_current_amd64.deb" -o /tmp/google-talkplugin-amd64.deb \
&& dpkg -i /tmp/google-talkplugin-amd64.deb
ADD https://dl.google.com/linux/direct/google-talkplugin_current_amd64.deb /src/google-talkplugin_current_amd64.deb

hope this helps someone

like image 118
JulioCT Avatar answered Oct 03 '22 05:10

JulioCT


You might want to take a look at projects like chromeless or puppeteer which both offer a feature-rich API as well as documentation on running on most hosting providers.

Alternatively, if you're looking for something custom-built for this then I run a SaaS called browserless that attacks the problem directly.

In any case, hope that helps

like image 41
browserless Avatar answered Oct 03 '22 03:10

browserless