我们在服务器centos 7安装的是chrome无头浏览器
1. 配置yum源
在目录 /etc/yum.repos.d/ 下新建文件 google-chrome.repo
cd /etc/yum.repos.d/
vim google-chrome.repo
写入如下内容:
[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
2.更新yum
3.安装Chrome无头浏览器
yum -y install google-chrome-stable --nogpgcheck
4.查看安装Chrome版本
Chrome 安装完毕
3.2安装Chrome驱动Chrome driver
Chrome版本Google Chrome 99.0.4844.51
查看与之对应的驱动版本
CNPM Binaries Mirror
下载chrome driver
https://registry.npmmirror.com/-/binary/chromedriver/99.0.4844.51/chromedriver_linux64.zip
解压
unzip chromedriver_linux64.zip
将Chrome driver移到/usr/local 下(这个随意,放哪儿都行)
mv chromedriver /usr/local
添加环境变量
PATH=$PATH:/usr/local
export PATH
![centos7 安装Chrome无头浏览器和驱动_chrome](//dev-img.mos.moduyun.com/20231025/2e838ddb-b59a-4ca5-b564-408ca02274c0.png)