Issue
I am creating a web server with Apache2 on a Raspberry Pi. There is one Problem. I want a python file to be executed by PHP like:
$result = shell_exec("python someFile.py");
echo "<pre>$result</pre>";
But if I want that file to run I have to make it readable. and then people can view the code and see sensitive information about the site. is there any way I can make the file be executed but not readable by any people. They would be able to see it if they went to the file like so:
PI_IP_ADDRESS/pyFile.py
Thanks for reading!
Solution
place the python file outside of the scope of apache. For example place the python file in your home directory, and then just call the file with the full directory in the php file.
$result = shell_exec("python ~/someFile.py");
Answered By - Daniel Smyth Answer Checked By - Senaida (WPSolving Volunteer)