Permission denied with wkhtmltopdf
Asked Answered
D

3

6

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 ?

Danielledaniels answered 17/3, 2016 at 15:29 Comment(1)
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-amd64Maricela
L
2

if you use net core or .net, use:

sudo chmod 777 -R <Directorio que contiene el wkhtmltopdf>

the error is caused because the program does not have writing permissions

Livingston answered 10/5, 2022 at 20:36 Comment(0)
L
1

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)

Lancastrian answered 15/3, 2018 at 10:39 Comment(0)
P
1

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

Parts answered 20/3, 2018 at 22:6 Comment(1)
Thanks... this worked for me! Just wanted to add the commands I used for linux (ubuntu). To copy to custom folder I used: sudo cp vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 /usr/local/bin/ this copied the file to the new custom location. I then made sure the permission were set up correctly using: sudo chmod +x /usr/local/bin/wkhtmltopdf-amd64. Finally as @Parts suggests I set it up in the config file, changing the binary setting inside de config.yml to the new location: 'binary' => '/usr/local/bin/wkhtmltopdf-amd64'.Maturate

© 2022 - 2024 — McMap. All rights reserved.