[Bug]: Inconsistent Behavior with spatie/laravel-pdf on Ubuntu OpenLiteSpeed Server #134
Replies: 1 comment
-
After some tinkering and using the deprecated puppeteer v17, as advised in the documentation, I received a different error:
This led me to a OpenLiteSpeed forum thread, where a potential fix would be to increase the memSoftLimit and memHardLimit limit of my webserver php. Increasing this to 80000M solved the issue, and I could process pdf's from my laravel app running on ubuntu 22.04 with OpenLiteSpeed. But I did not want to be using puppeteer v17 and neither did I want to rely on globally installed puppeteer packages when I am running nvm with my project. It was a struggle to get the latest puppeteer to work with nvm, but I managed to do it in the end with this default config: Pdf::default()
->withBrowsershot(function ($browsershot) {
$browsershot
->setIncludePath('$PATH:'.config('browsershot.include_path'))
->addChromiumArguments([
'headless=shell'
]);
}); I found that Hope this is usefull for anyone. |
Beta Was this translation helpful? Give feedback.
-
What happened?
When attempting to generate a PDF using spatie/laravel-pdf from a browser request on a remote Ubuntu 22.04 server running OpenLiteSpeed with PHP 8.2 and NVM Node, it fails with a browser process launch error. However, running the same functionality via CLI on the server works as expected and the PDF is generated.
When I try to save a test pdf like this:
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
:I have tried everything from the pptr troubleshooting, without luck.
I expected the PDF generation to work from the browser request just as it does when executed from the CLI, without any errors.
How to reproduce the bug
I made an MWE laravel project to investigate this: https://github.com/kaspernowak/laravel-pdf
Follow the testing instructions in the repository readme:
Testing instructions
Test node and puppeteer setup
test-pptr.cjs
from your CLI with node:npm list
to verify that puppeteer is installed, if you get any errors.Test PDF saving from browser
hello_world.pdf
pdf file has been saved successfully to your projects/public
directory.Test PDF saving from CLI using your Virtual Host executable user (depends on your OpenLiteSpeed setup)
/test-pdf
route with the customroute:call
command:Package Version
1.5.0
PHP Version
8.2
Laravel Version
11.5
Which operating systems does with happen with?
Linux
Notes
I am suspecting that this has something to do with running this on a OpenLiteSpeed webserver, as it works when the project runs with
php artisan serve
.Beta Was this translation helpful? Give feedback.
All reactions