I wrote php script (test.php) that calls a python function.
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
error_reporting(-1);
echo "php: code started\n";
$command = escapeshellcmd("/usr/bin/python /var/www/html/pythontest.py");
$output = shell_exec($command);
echo $output;
?>
If I call this function from command line as php test.php
, it runs perfectly, but when I call this php code from a html page, the code does not run. The html page is showing as it should, though.
My html page is as follows:
<!DOCTYPE html>
<html>
<body>
PHP test page
<?php include 'test.php';?>
</body>
</html>
No errors are reported in /var/log/apache2/error.log
Does anyone have an idea why the php code is not running? Embedding the php code literally in the html file did not work as well. I'm working on an Ubuntu AWS EC2 machine.