From a PHP script I want to run a Perl script. I can do this fine from the terminal (as root user) but when run from my application (www-data user) I can't.
When developing the application on localhost I was able to do this fine as well, but the problem appeared when I switched to another server.
My webpage calls the PHP script with an AJAX POST request, which works fine for my other PHP scripts that do not make calls to Perl.
I have tried the following commands in my PHP script with no success:
system("/filepath/file.pl");
exec("/filepath/file.pl");
passthru("/filepath/file.pl");
The Apache logs on the server hosting my application show the following error:
sh: /file.pl: not found
From running the following code on my server I see that the web user is seen as www-data:
ps aux | grep apache
To test, I have also set the permissions for all files and directories use by my application to allow any type of access by any user, using chmod 777.
Please note: my application is only available to certain users (I use a .htaccess file to set these permissions and require the user to login) so if there is a way to change how the server sees this user (from www-data, to the credentials of the logged-in user) then perhaps that would help - how would I do this?