3
votes

I have installed Wkhtmltopdf and I have this error when I execute him "/var/chroot/wkhtmltox-jessie-amd64: Permission denied". I search in Google but I have not found how to do ... repertory have this permission "drwxr-xr-x root root" and i execute him in web-server (apache) and Symfony.

Error :

The exit status code '126' says something went wrong: stderr: "sh: 1: /var/chroot/wkhtmltox-jessie-amd64: Permission denied " stdout: ""

Can you help me ?

2
I guess, that webserver user (apache) doesnt have write access to mentioned directory (which is owned by root), so under root user you need to change permissions of the directory: chmod 777 /var/chroot/wkhtmltox-jessie-amd64 or change ownership to apache user: chown apache.apache /var/chroot/wkhtmltox-jessie-amd64Miro

2 Answers

1
votes

I encountered the same problem on the server; it was weird that the local version was happily doing its job. After changing the generated file's destination folder permissions without any luck, I realised that the problem whas caused by the binary path in config.yml. I changed it from:

/opt/wkhtmltox/bin/wkhtmltopdf.exe

to:

/opt/wkhtmltox/bin/wkhtmltopdf

Now all it's ok.

PS: if you don't keep wkhtmltopdf in the vendor's file (my case), create a knp_snappy config in config_prod.yml; the paths are different from local to prod version.

Here is the official documenation of KnpLabs Bundle for more info.

Good luck ! (in case you needed any 'after 1 year and 11 months' answear)

1
votes

Install library Wkhtmltopdf on custom folder in the user directory for linux or mac save this route and set in your config

This solution working in production server

This error is because var and opt folder you can't write any content if not root user