I am trying to run a simple python script through php on Amazon EC2 instance.
The file is working fine on terminal i.e am getting the output. But when am trying the same in browser, am getting a blank page.
I tried few things, such as adding www-data ALL=(ALL) ALL
in sudoers file in etc folder. etc/sudoers
.
I also tried disabling SELINIX
.
I checked with the php's safe mode and few other things which I found over here(SO).
I have followed this AWS TUTORIAL. I did everything exactly what's written in there. I believe there is some permission issue.
Can anyone please check it out. Am stuck with this for 2 days..
EDIT Python script
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# enable debugging
import cgitb
print "Hello world"
cgitb.enable()
Php file:
<?php header("Content-Type:text/plain");
$output = escapeshellcmd('/home/ec2-user/anaconda/envs/xyz/bin/python2.7 /var/www/html/xyz/a.py');
$a=shell_exec($output);
echo ($a);
//echo file_get_contents("/var/www/html/xyz/a.py");
?>