Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using CentOS 6.3x64.

I'm trying to run wkhtmltopdf (from here) from a PHP script. I can successfully call wkhtmltopdf-amd64 directly via SSH. But when calling it from PHP via exec, it always fails with exit code 127. The path is correct, so that isn't the issue. I can successfully use exec to call ls and id etc, so the problem seems to be specific to calling wkhtmltopdf-amd64.

I would presume this somehow relates to permissions, but I'm not sure what steps to take. I've tried apache:apache and other ownerships on the program and it has 755 permissions.

Thanks for any guidance!

Additional note:

Sorry for not clarifying further above -- I have confirmed the issue does not relate to the path to the program. I'm using the full absolute path. I've confirmed that the exact same command can be run from the SSH line without problem (regardless of the pwd). I've also created a shell script:

echo 'hello, world!'

I can call this script via exec and it works properly. However, if I modify it to be

echo 'hello, world!'
/full/path/to/wkhtmltopdf-amd64 '' /full/path/to/output.pdf

it then fails and returns the exit code 127.

share|improve this question

Your shell seems to be unable to find the binary. Try calling it with its full path name (e.g. /usr/bin/ls instead of ls). For further information, see man bash

share|improve this answer
thanks for the advice; unfortunately, the path isn't the issue (see additional clarification added to the question). – N Rohler Feb 23 '13 at 16:16

I had the same issue a while back. In my case I got 126 without the execution bit set and 127 with the bit set.

I later figured out it was related to some shared libraries missing on the system. Even if the binary is linked statically it seems to use some shared libraries from the system.

I don't really remember which libraries were causing the problem, but this gist: is a good starting point I think.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.