Google Chrome Headless is a browser mode without a graphical user interface, making it perfect for automated web tasks such as testing, data scraping, and generating PDFs or screenshots. To start these tasks on Linux systems, you first need to install Google Chrome on Ubuntu. This setup is widely used in CI/CD pipelines for web automation, allowing developers to efficiently run UI tests without a visible browser window, which speeds up testing and reduces resource consumption.
If you want to run Google Chrome in headless mode for automated tasks or server-based browsing, this guide will walk you through the steps to install Google Chrome Headless on an Ubuntu server.
Prerequisites
- Access to an Ubuntu server.
- sudo privileges to install and configure packages.
Step 1: Update the Package Index
Update the package index to ensure all repositories are in sync:
#apt-get update
Step 2: Install Dependencies
Install the required dependencies for Chrome:
#apt-get install libappindicator1 fonts-liberation
Step 3: Download Google Chrome
Use wget to download the latest version of Google Chrome:
#wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Step 4: Install Google Chrome
Install the Chrome package using dpkg. This may show some dependency errors, which we’ll resolve in the next step:
#dpkg -i google-chrome-stable_current_amd64.deb
Step 5: Fix Broken Dependencies
Resolve any missing dependencies:
#apt --fix-broken install
Step 6: Re-run the Chrome Installation
After fixing dependencies, rerun the Chrome installation:
#dpkg -i google-chrome-stable_current_amd64.deb
Step 7: Verify the Installation
To check if Google Chrome is installed and functioning, run:
#google-chrome-stable --version
Example Command: Run Chrome in Headless Mode
To generate a PDF of a webpage, you can use:
#google-chrome-stable --headless --disable-gpu --print-to-pdf https://example.com/
Note: Replace example.com with the domain you want to process.
With these above mentioned steps, you can successfully install Google Chrome Headless on your Ubuntu server, and handle automated browsing, screenshots, or testing scripts.
Have any queries related to “How to Install Google Chrome Headless on Ubuntu Server”? Contact us, and we’ll get back to you within no time!