Permission Denied
Ok, when I run this command from the command line it works:
/usr/local/bin/prince --verbose -s "/var/www/html/dolphinedc_com/public/media/css/interviewsummary.css" -s "/var/www/html/dolphinedc_com/public/media/css/global.css" -s "/var/www/html/dolphinedc_com/public/media/css/style.css" -s "/var/www/html/dolphinedc_com/public/media/css/prince.css" -i "html" --log="/var/www/html/dolphinedc_com/interviewsummaries/2010010101/50414/Prince.log" "/var/www/html/dolphinedc_com/interviewsummaries/2010010101/50414/InterviewSummary.html"
When I run it from within my php application I get
08:18:56:791840!snmkc66in3vtop4jrms52fbe74!index!line = /usr/local/bin/prince: line 3: /usr/local/lib/prince/bin/prince: Permission denied
08:18:56:791974!snmkc66in3vtop4jrms52fbe74!index!line = /usr/local/bin/prince: line 3: /usr/local/lib/prince/bin/prince: Success
Not sure why I would get a permission denied and then a Success on the same call but I am. I have checked the permission for all of the directories and files and they are all set to r_xr_xr_x.
Also I do not get a log file created when running it from with my php app.
Can you run Prince successfully from the command-line? Which operating system are you running, and is the correct Prince package installed?
Yes,
GNU/Linux
Not sure, how would I tell?
If it works from the command line wouldn't that tell me I have the right package installed?
Yes, that is a good sign. The error message is a bit strange though: it seems to be successfully running the Prince shell script in /usr/local/bin/prince, and then that tries to exec the Prince binary in /usr/local/lib/prince/bin/prince, but the exec fails.
If it runs fine from the command-line, that would suggest that PHP is using a different environment in some way. It is definitely running as a different user, but you would assume it can still access the executable. Perhaps it has changed LD_LIBRARY_PATH so some shared libraries are not available, or some other weirdness.
We can debug this, but it will take patience. A good place to start is by temporarily modifying the Prince shell script in /usr/local/bin/prince. For example, before the exec you could add "touch /tmp/yay", then if the file /tmp/yay shows up it confirms that the shell script did indeed run.
After that, you could try adding "file /usr/local/lib/prince/bin/prince > /tmp/yay 2>&1" and paste the output that you get, that should show whether the binary is readable.
Step 1: Ok added touch /tmp/yay and re-ran the app. The yay file did show up in temp. on to step two.
Step 2: Here is what was in the yay file:
/usr/local/lib/prince/bin/prince: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU/Linux 2.6.15, stripped
Could it be a 32/64 bit issue?
When I do a uname -a I get the following:
Linux DOLPHIN2 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
In that case it would definitely be worth trying the 64-bit Prince package.
Do I need to de-install the 32bit package before installing the 64 bit package?
Installed 64 bit package and re-ran, yay contents are as follows:
/usr/local/lib/prince/bin/prince: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU/Linux 2.6.15, stripped
Look like 32 bit is still being used. Am I reading it right?
Yes. Which package did you install? The DEB and RPM packages will install Prince in /usr, not /usr/local.
The RPM package. I am not seeing prince in the /usr directory. I am seeing it in the /usr/local/bin and usr/local/lib directory. So I need to uninstall prince and then reinstall the 64 bit version correct?
Ok I did all that and re-ran the app and the yay file contained the following:
/usr/local/lib/prince/bin/prince: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.6.15, stripped
but still no pdf output. So it looks like we are running the 64-bit version.
The binary included in the RPM package is not statically linked, and should end up in /usr not /usr/local. What output do you get if you run "rpm -ql prince" from the command-line?
package prince is not installed
I ran the ./install.sh in the prince-8.1r5-linux-amd64-static directory to install prince. So I guess not RPM...
Right, that solves the question of which package was installed. But doesn't solve the question of why it works when you run it manually from the command-line, but fails when invoked from PHP.
StackOverflow suggests that probably either PHP safemode is enabled, or SELinux security permissions are preventing Apache from executing external processes.
Yes I am running under the user apache. I tried adding apache to the root group and it still did not work.
I also tried changing the ownership of the prince file in /usr/local/lib/prince/bin to apache:apache and still no go...
I have even tried changing the ownership of the directories to apache to see if that would work. The issue is I can't tell "what" permission is denied. Is it permission to run the prince app? Access to a specific directory? etc?
By the way PHP safemode is turned off.
Mike, thanks for all you help. My issue was with the SELinux security. It was set to enforce. When I set it to Permissive the prince stuff works.
Great!