I have been struggling with an issue for the past few days now, regarding using spatie/laravel-pdf on my remote ubuntu 22.04 server running openlitespeed with php 8.2 with nvm node.
I made an MWE laravel project to investigate this: https://github.com/kaspernowak/laravel-pdf
What I fail to understand, is that when I try to save a test pdf like this:
Route::get('/test-pdf', function () { $htmlContent = "<h1>Hello World!</h1><p>This is a test PDF generated from HTML.</p>"; $pdfPath = public_path('hello_world.pdf'); Pdf::html($htmlContent) ->withBrowsershot(function ($browsershot) { $browsershot ->setIncludePath('$PATH:'.config('browsershot.include_path')) // Necessary for this to work with nvm. }) ->save($pdfPath); return 'PDF generated and saved to ' . $pdfPath;});
It just works from my local ubuntu machine when navigating to /test-pdf
, with a local install of nvm and puppeteer with node.
When I pull my repository on my remote ubuntu server with the same puppeteer setup, I always get this error when navigating to /test-pdf
:
Error Output:================Error: Failed to launch the browser process!TROUBLESHOOTING: https://pptr.dev/troubleshooting
I have tried everything from the pptr troubleshooting, without luck.
The weird thing is, that when I run puppeteer from the CLI as the executable user of the laravel project vhost on the remote server, the /test-pdf just works and a pdf is saved to my public directory.
Does anyone know what could be causing this issue, when it works from the CLI but not from the browser?