Skip to content Skip to sidebar Skip to footer

Can't Execute Python Script From Php

Solved Before writing a new question i search for a solution all over the web. I have a raspberry pi with apache2, php5.4,ssl. I want to execute a python script from php one. The p

Solution 1:

Your problem is this: When launching the php script through the console, you are launching php with the permissions of your current user. When a process is executed through opening it in the browser, it will have the permissions of the user of your web-server-process.

Your group permissions will have to be 7 no matter what. Either change the python scripts permissions to 777 (read-write-execute for everybody) or change it to 770 and make sure that your web-servers user is inside the group set to the file.

Solution 2:

I had an issue similar while trying to build a web interface to change the image on an inky pHAT. Turns out www-data doesn't have access to GPIO.OUT. Tested by running "sudo -u www-data php index.php" and it returned the error I was looking for. So I give www-data GPIO permission "usermod -a -G gpio www-data" instead of adding to suddoers.

Post a Comment for "Can't Execute Python Script From Php"