Hi, I get an error executing wkhtmltopdf-amd64:
The exit status code '126' says something went wrong:
stderr: "sh: /home/centos/apps/mainstay-v2-staging/releases/20171006033718/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: Permission denied
"
stdout: ""
command: /home/centos/apps/mainstay-v2-staging/releases/20171006033718/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 --lowquality '/tmp/knp_snappy59d6fba6299db4.19756944.html' '/tmp/knp_snappy59d6fba629a7a7.69816429.pdf'.
Details:
composer dependency installed "barryvdh/laravel-snappy": "^0.4.0", in Laravel 5.4
wkhtmltopdf-amd64 bin file already has 777 permission
app running on AWS ec2 centos7 server on nginx (nginx user is also centos)
I know this is a permissions issue, but bin file already has 777 permission.
Could it be the permissions on tmp? But this only happens when a different user is the one generating /tmp/knp_snappy59d6fba6299db4.19756944.html and /tmp/knp_snappy59d6fba629a7a7.69816429.pdf. Let me know if my assumptions are correct.
Also tried to install wkhtmltopdf patched qt, added +x permissions, and it still gives me a permission denied error:
The exit status code '126' says something went wrong:
stderr: "sh: /usr/bin/wkhtmltopdf: Permission denied
"
stdout: ""
command: /usr/bin/wkhtmltopdf --lowquality '/tmp/knp_snappy59d72708718be4.25051346.html' '/tmp/knp_snappy59d72708719585.22585854.pdf'.
By the way I can also execute wkhtmltopdf standalone in the command line.
Ok, turns out it was selinux that's causing the permission denied.
Figured it out by setenforce 0
But I need selinux enabled. Anyone knows which selinux boolean to enable?
Was able to allow running wkhtmltopdf through nginx with selinux enabled with this command:
sudo semanage permissive -a httpd_t
@krtorio To be more restrictive you can use someting like this:
chcon -R -t httpd_sys_script_exec_t /var/www/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64
Most helpful comment
Was able to allow running wkhtmltopdf through nginx with selinux enabled with this command:
sudo semanage permissive -a httpd_t