In a symfony4 project I use KNP Snappy with wkhtmltopdf to generate pdf-files. This works on my computer and on my server. On my server I have created a folder called 'dev' where I can test my project (I have created a copy there). When I set the .env file to prod
in my test-project all works fine, including generating pdf-files.
Here's the odd thing: on my actual production site (in the folder above) all code is exactly equal to the project in the 'dev folder', however whenever I try to generate a pdf-file I get a good old 500 Internal server error
.
This is my config-file knp_snappy.yaml:
knp_snappy:
pdf:
enabled: true
binary: '%kernel.root_dir%/../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'
options: []
image:
enabled: true
binary: '%env(WKHTMLTOIMAGE_PATH)%'
options: []
This should just work, but it does not. I tried changing the files around, changing the paths, but no luck. Could it be a folder permission issue? What else could be different between the two projects since the code is exactly the same? It's hard for me to solve this issue because I cannot reproduce the problem when testing and I can't find out anything about the error. Any help is greatly appreciated.
Update of what I tried so far: I reinstalled the dependencies. I changed the permissions for the folder tmp
, I made sure the pdf I tried to generate did not contain anything. I cleared the cache (obviously), but still an error.
I managed to find the problem. The file
wkhtmltopdf-amd64
did not have the right permissions set. I needed execute permission, so I set it the permissions to rwxrw-r-- (0764) and now it all works. For some reason in the dev-folder the file DID have execute permissions set.