安装chrome

创建yum源

# cd /etc/yum.repos.d/
# vim google-chrome.repo

创建yum源信息

[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

安装google-chrome

# yum -y install google-chrome-stable --nogpgcheck

chrome安装路径

使用上述步骤安装完成之后,chrome的安装路径在/opt/google/chrome目录下

安装chromeDriver

查看chrome版本

# google-chrome -version

下载对应版本的chromeDriver

从https://npm.taobao.org/mirrors/chromedriver/查询与chrome版本对应的chromeDriver版本,大版本对应即可,如当前chrome最新的版本是78.0.3904.97,只需要查找与78对应的chromeDriver版本即可。

找到对应的版本后,在linux上使用以下命令下载chromeDriver压缩包:

# mkdir /usr/chromedriver
# cd /usr/chromedriver
# wget https://npm.taobao.org/mirrors/chromedriver/version/chromedriver_linux64.zip

version为chromeDriver的完整版本号

下载之后解压压缩包:

# unzip chromedriver_linux64.zip

给chromeDriver文件夹赋予权限:

# chmod +x /usr/chromedriver/chromedriver

安装Xvfb

安装说明

安装此软件的原因是在centos上,chromeDriver必须使用无头模式,当有不使用无头模式的需求时就需要安装此软件,否则chromeDriver无法正确启动chrome

安装Xvfb

# yum install Xvfb -y
# yum install xorg-x11-fonts* -y

在/usr/bin/目录下创建xvfb-chrome文件

# vim /usr/bin/xvfb-chrome

在xvfb-chrome文件中输入以下内容

#!/bin/bash

_kill_procs() {
kill -TERM $chrome
wait $chrome
kill -TERM $xvfb
} # Setup a trap to catch SIGTERM and relay it to child processes
trap _kill_procs SIGTERM XVFB_WHD=${XVFB_WHD:-1280x720x16} # Start Xvfb
Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp &
xvfb=$! export DISPLAY=:99 chrome --no-sandbox --disable-gpu$@ &
chrome=$! wait $chrome
wait $xvfb

添加执行权限:

# chmod +x /usr/bin/xvfb-chrome

查看当前的映射关系:

# ll /usr/bin/ | grep chrom

映射关系如下所示:

lrwxrwxrwx 1 root root 31 Nov 18 14:25 chrome -> /etc/alternatives/google-chrome
lrwxrwxrwx 1 root root 20 Nov 18 14:25 google-chrome -> /usr/bin/xvfb-chrome
lrwxrwxrwx 1 root root 32 Jun 28 18:39 google-chrome-stable -> /opt/google/chrome/google-chrome
-rwxr-xr-x 1 root root 422 Nov 18 14:24 xvfb-chrome

更改chrome启动的软连接:

# ln -s /etc/alternatives/google-chrome /usr/bin/chrome
# rm -rf /usr/bin/google-chrome
# ln -s /usr/bin/xvfb-chrome /usr/bin/google-chrome

此时再次查看映射关系,如下所示:

lrwxrwxrwx 1 root root 31 Nov 18 14:36 chrome -> /etc/alternatives/google-chrome
lrwxrwxrwx 1 root root 20 Nov 18 14:36 google-chrome -> /usr/bin/xvfb-chrome
lrwxrwxrwx 1 root root 32 Jun 28 18:21 google-chrome-stable -> /opt/google/chrome/google-chrome
-rwxr-xr-x 1 root root 422 Nov 18 14:36 xvfb-chrome

以上步骤操作完成后即可在centos环境下使用非无头浏览器,此时chromeDriver创建时不能再添加以下参数:

options.addArguments("--headless")

centos7安装chrome+chromeDriver+Xvfb的更多相关文章

  1. CentOS-yum安装chrome+chromeDriver+xvfb

    安装chrome 创建yum源文件 $ vim /etc/yum.repos.d/google-chrome.repo [google-chrome] name=google-chrome baseu ...

  2. centos7安装chrome及加载poatman开发插件

    为什么要安装chrome?因为centos7的默认浏览器firefox的实在是不习惯,上面占了太多,本来显示器就不大... 好了,首先下载chome的rpm安装包(如果需要的可以留言,我有备份) 然后 ...

  3. CentOS7 安装chrome浏览器

    本篇文章主要记录如何在CentOS7.0上安装chrome. 1.配置yum下载源: 在目录 /etc/yum.repos.d/ 下新建文件 google-chrome.repo, 并且在该文件中添加 ...

  4. 【转载】CentOS7 安装Chrome浏览器

    本篇文章主要记录如何在CentOS7.0上安装Chrome浏览器. 方法1: Google官方源在国内可能无法正常访问,故而添加Fedora中文社区提供的镜像源: sudo wget http://r ...

  5. CentOS7 安装Chrome

    1. 下载Chrome浏览器的rpm包 https://www.chrome64bit.com/index.php/google-chrome-64-bit-for-linux 2. 安装Chrome ...

  6. centos7安装chrome的历程(fedora同)

    安装 首先是下载,地址奉上:http://www.google.cn/chrome/browser/desktop/index.html,选择64 bit .rpm (适用于 Fedora/openS ...

  7. Linux Centos7安装chrome浏览器

    参考:https://blog.csdn.net/u010472499/article/details/72327963 1. 配置yum源 在目录 /etc/yum.repos.d/ 下新建文件 g ...

  8. centos7安装chrome浏览器

    1.配置yum下载源: 在目录 /etc/yum.repos.d/ 下新建文件 google-chrome.repo, 并且在该文件中添加如下内容: [google-chrome]name=googl ...

  9. CentOS7安装Chrome

    1. 进入官网:https://www.google.cn/intl/zh-CN/chrome/2. 点击下载3. 直接安装:sudo yum localinstall google-chrome-s ...

随机推荐

  1. VS 中的 lib 和 dll 的区别和使用

    在 vs/c# 项目开发中,经常会遇到 lib 和 dll 文件,而且创建工程项目以及工程项目打包时也是必须要面对的,所以有必要掌握 lib 和 dll 的区别和使用. 静态库:在链接步骤中,连接器将 ...

  2. DOCKER学习_012:Dockerfile配置指令详解

    1 Dockerfile结构 基础镜像信息 镜像操作指令 容器启动时执行指令 2 FROM 指定基础镜像,用于继承其他镜像使用的 FROM ubuntu:14.06 FROM centos FROM ...

  3. rpm命令的简介(2)-(转自 青春乐园 )

    青春乐园 怎样查看rpm安装包的安装路径 rpm -qpl xxxxxx.rpm 1.如何安装rpm软件包 rmp软件包的安装可以使用程序rpm来完成.执行下面的命令 rpm -i your-pack ...

  4. SUSE12 操作系统安装

    今天开发同事需要一个客户的SUSE环境,原来没有安装过这个操作系统,网络配置方面有些问题见下一篇 镜像:SLE-12-SP3-Server-DVD-x86_64-GM-DVD1.iso 安装过程: 选 ...

  5. Java 的序列化 (Serializable)(Day_09)

    我们的火,要把世界都点燃 运行环境 JDK8 + IntelliJ IDEA 2018.3 什么是序列化,反序列化 序列化是将对象状态转换为可保持或传输的格式的过程. 与序列化相对的是反序列化,它将流 ...

  6. Git 上传基本命令

    注意:操作要保证在对应文件夹中打开Git bash here (例如:clone项目后要cd到文件中,否则报"git提示没有git存储库") 1.创建一个git裸服务器 (git ...

  7. win系统下如何安装xgboost,开发环境是anaconda,以及这中间需要注意的问题

    最近学到了xgboost,但是anaconda并没有这个环境只好自己安装了... 注: (1)并没有测试anaconda在2.x的版本下是如何安装的, 基本上应该是大同小类的,我的anaconda版本 ...

  8. 3D惯导Lidar仿真

    3D惯导Lidar仿真 LiDAR-Inertial 3D Plane Simulator 摘要 提出了最*点*面表示的形式化方法,并分析了其在三维室内同步定位与映射中的应用.提出了一个利用最*点*面 ...

  9. Gbps接口面向汽车应用

    Gbps接口面向汽车应用 Gbps interfaces target automotive appications 巴黎--不久前,移动通信行业是一个领着芯片商的领头羊,命令坐着,脚跟着,然后翻身. ...

  10. SpringBoot2 参数管理实践,入参出参与校验

    一.参数管理 在编程系统中,为了能写出良好的代码,会根据是各种设计模式.原则.约束等去规范代码,从而提高代码的可读性.复用性.可修改,实际上个人觉得,如果写出的代码很好,即别人修改也无法破坏原作者的思 ...