I have a python program to control GPIO of raspberry pi. Webserver installed is apache2. But when accessing GPIO from the program I get an error to run the program as root since /dev/mem is not accessible.How to run the program as root since I have placed the python file in /var/www so that it is accessible as webpage?Security is not a concern.

1 Answer 1


I'm assuming that you are using cgi, in which case you need to set the owner of the script to root and set its suid bit. If python won't work with suid, you can use supper.

  • 2
    You should explain why chown the /dev/mem is a bad idea. Also you should explain how to set the suid bit Commented Dec 7, 2013 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.