Install Chrome as the www-data User

John Beales June 11, 2026
Source
After recently rebuilding the 4RoadService web server on Debian 13, Browsershot wasn’t working right. It wasn’t working at all. We run Laravel on a slightly old-school LAMP setup with PHP-FPM, and run the Laravel workers as the www-data user, the same user that runs the web server, so that user needed to be able to run puppeteer and Chrome, which wasn’t possible with each user having its own nvm/node/npm installation. Installing Node & NPM Globally The Node docs now suggest installing NPM/Node per user, but when setting this up I hadn’t figured out how to install anything only for www-data yet, so I installed Node globally with apt. sudo apt-get install npm With Node in stalled I could install puppeteer globally: sudo npm install -g puppeteer Installing Browsers Then I needed to make sure that the www-data user had a home directory it could write to to install the cached versions of Chrome that puppeteer uses: sudo mkdir -p /var/www/.cache && sudo chown -R www-data:www-data /var/www It seems that /var/www acts as www-data’s home directory in Debian 13 Trixie but www-data doesn’t actually own it, so we made the www-data’s ~/.cache directory then set www-data’s ~, and its contents, to be owned by www-data:www-data (user www-data and group www-data). With the directory ready I was able to install Chrome and Chrome Headless Shell as www-data: sudo -u www-data npx puppeteer browsers install chrome sudo -u www-data npx puppeteer browsers install chrome-headless-shell Install some packages as suggested by the Browsershot docs: sudo apt update sudo apt install libx11-xcb1 libxcomposite1 libasound2t64 libatk1.0-0 libatk-bridge2.0-0 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 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 And it turned out that libnss3 is required by Chrome and wasn’t mentioned by the Browsershot docs but is needed, so install that: sudo apt-get install libnss3 And Chrome was up and running and my queue jobs could generate PDFs with Browsershot. Unfortunately, I couldn’t generate the PDFs synchronously in a web request.

Discussion in the ATmosphere

Loading comments...