简体   繁体   English

在亚马逊上安装 Chromium Linux

[英]Installing Chromium on Amazon Linux

I am trying to install Chromium (or Chrome, whichever) on an Amazon Linux machine.我正在尝试在 Amazon Linux 机器上安装 Chromium(或 Chrome,以两者为准)。

I have tried many steps, to no avail.我尝试了很多步骤,但无济于事。 Here is what I have tried:这是我尝试过的:

Simple Yum Install简单的百胜安装

yum install epel       # worked
yum install chromium

generated error message:生成的错误信息:

 Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6) Requires: libgnome-keyring.so.0()(64bit) Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6) Requires: libgtk-x11-2.0.so.0()(64bit) Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6) Requires: libgdk_pixbuf-2.0.so.0()(64bit) Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6) Requires: libXss.so.1()(64bit) Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6) Requires: libgdk-x11-2.0.so.0()(64bit) Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6) Requires: libcanberra-gtk2(x86-64) Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6) Requires: libatk-1.0.so.0()(64bit)

Yum install of specific RPM package百胜安装特定的RPM package

I tried downloading a Chrome RPM, both the latest stable version as well as a specific version, and then running我尝试下载 Chrome RPM,包括最新的稳定版本和特定版本,然后运行

yum install google-chrome-stable-64.0.3282.119-1.x86_64.rpm

It yielded the same error message它产生了相同的错误信息

Manual procedure手动程序

Downloaded binary from https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/532015/https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/532015/下载二进制文件

Running it generated the error message运行它会生成错误消息

error while loading shared libraries: libXcursor.so.1: cannot open shared object file: No such file or directory加载共享库时出错:libXcursor.so.1:无法打开共享 object 文件:没有这样的文件或目录

I ran我跑了

yum install libXcursor
yum install libXfixes     # because chrome was then complaining about that library
yum install libXdamage    # and subsequently that one

which all worked.这一切都奏效了。

However, then Chrome started complaining about a libcups library:然而,Chrome 开始抱怨libcups库:

error while loading shared libraries: libcups.so.2: cannot open shared object file: No such file or directory加载共享库时出错:libcups.so.2:无法打开共享 object 文件:没有这样的文件或目录

libcups wasn't found by yum, and it seems that this is because it is a 32 bit library. yum 找不到libcups ,这似乎是因为它是一个 32 位库。 Some page recommended to install ia32-libs as a solution, but running yum install ia32-libs showed that it was already installed.一些页面建议安装ia32-libs作为解决方案,但运行yum install ia32-libs显示它已经安装。

I couldn't get past that point.我无法超越那个点。

Other其他

  • I also tried steps mentioned here , but that didn't work我也尝试了这里提到的步骤,但是没有用
  • some pages point to using dpkg , but that command doesn't exist on Amazon Linux apparently一些页面指向使用dpkg ,但该命令显然在亚马逊 Linux 上不存在
  • apt neither都不apt

None of these answers , work, and none of them actually solves problem for amazon linux,这些答案都不起作用,而且它们都没有真正解决亚马逊 linux 的问题,

To really solve the problem if you are using EC2 instance or any other server where you are running Amazon linux, you should follow the below steps .如果您正在使用 EC2 实例或任何其他运行 Amazon linux 的服务器,要真正解决问题,您应该按照以下步骤操作。

  1. Enable and install Extra Packages for Enterprise Linux by running the command通过运行命令为 Enterprise Linux 启用并安装 Extra Packages

     sudo amazon-linux-extras install epel -y
  2. Post installing all the extra packages successfully, Install chromimum as usual成功安装所有额外的软件包后,照常安装 chromimum

     sudo yum install -y chromium

Once you do that Chromium will have all required such as libatk* libgdk* etc ...一旦你这样做了,Chromium 将拥有所有必需的东西,例如 libatk* libgdk* 等......

You should be able to easily launch Chromium您应该能够轻松启动 Chromium

The missed out packages that you are looking here, are actually not missedout they are kind of default you just have to enable them , this is well documented in AWS documentation .您在此处查看的遗漏包实际上并没有遗漏它们是默认设置,您只需启用它们,这在 AWS 文档中有详细记录。

https://aws.amazon.com/premiumsupport/knowledge-center/ec2-enable-epel/ https://aws.amazon.com/premiumsupport/knowledge-center/ec2-enable-epel/

In order to get headless chrome working on Lambda, I deployed an identical AMI as an EC2 instance (currently amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2).为了让无头 chrome 在 Lambda 上工作,我部署了一个与 EC2 实例相同的 AMI(当前是 amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2)。 After installing chrome, the usual litany of missing dependencies begins.安装 chrome 后,通常会出现一连串缺少依赖项的情况。

Reference: https://medium.com/mockingbot/run-puppeteer-chrome-headless-on-ec2-amazon-linux-ami-6c9c6a17bee6参考: https : //medium.com/mockingbot/run-puppeteer-chrome-headless-on-ec2-amazon-linux-ami-6c9c6a17bee6

Navigate to the folder containing the chrome executable and use ldd to check for missing dependencies:导航到包含 chrome 可执行文件的文件夹并使用 ldd 检查缺少的依赖项:

$ ldd chrome | grep not
libpangocairo-1.0.so.0 => not found
libpango-1.0.so.0 => not found
libcairo.so.2 => not found
libXcursor.so.1 => not found
libXdamage.so.1 => not found
libXfixes.so.3 => not found
libcups.so.2 => not found
libXss.so.1 => not found
libXrandr.so.2 => not found
libgconf-2.so.4 => not found
libatk-1.0.so.0 => not found
libgtk-3.so.0 => not found
libgdk-3.so.0 => not found
libgdk_pixbuf-2.0.so.0 => not found

Install the following:安装以下内容:

$ sudo yum install cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango

Check again:再次检查:

$ ldd chrome | grep not
libXss.so.1 => not found
libgconf-2.so.4 => not found
libatk-1.0.so.0 => not found
libgtk-3.so.0 => not found
libgdk-3.so.0 => not found
libgdk_pixbuf-2.0.so.0 => not found

We need to grab these dependencies from a maddeningly large set of RPMs:我们需要从一组令人发狂的 RPM 中获取这些依赖项:

# Install ATK from CentOS 7
$ 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 GTK from fedora 20
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/GConf2-3.2.6-7.fc20.x86_64.rpm
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libXScrnSaver-1.2.2-6.fc20.x86_64.rpm
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libxkbcommon-0.3.1-1.fc20.x86_64.rpm
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-client-1.2.0-3.fc20.x86_64.rpm
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-cursor-1.2.0-3.fc20.x86_64.rpm
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/gtk3-3.10.4-1.fc20.x86_64.rpm
# Install Gdk-Pixbuf from fedora 16
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/16/Fedora/x86_64/os/Packages/gdk-pixbuf2-2.24.0-1.fc16.x86_64.rpm

That should resolve all the dependencies and chrome should be able to run, finally!!这应该解决了所有的依赖关系,chrome 应该能够运行了,最后!!

I use chromium for headless testing via AWS Ubuntu launched through CodeBuild.我使用 Chromium 通过通过 CodeBuild 启动的 AWS Ubuntu 进行无头测试。 I found I had to update node and install a set of chromium dependencies.我发现我必须更新节点并安装一组铬依赖项。

#!/bin/sh
echo "Installing nodejs (which will include node and npm)"
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs  
echo "Installing chromium dependencies"
apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

For those using Amazon Linux 2022, there are several packages missing, running ldd chrome | grep not对于那些使用 Amazon Linux 2022 的用户,缺少几个包,运行ldd chrome | grep not ldd chrome | grep not in the Chromium directory yields: ldd chrome | grep not Chromium 目录中产生:

    libnss3.so => not found
    libnssutil3.so => not found
    libsmime3.so => not found
    libnspr4.so => not found
    libgbm.so.1 => not found

These packages aren't available for Amazon Linux 2022 but you can find them on https://rhel.pkgs.org/8 which works because this distribution is based on RHEL 8.这些软件包不适用于 Amazon Linux 2022 ,但您可以在https://rhel.pkgs.org/8上找到它们,因为此发行版基于 RHEL 8。

So these should fix it:所以这些应该解决它:

sudo dnf install http://repo.okay.com.mx/centos/8/x86_64/release/okay-release-1-1.noarch.rpm
sudo dnf install nss
sudo dnf install mesa-libgbm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM