LoginSignup
1
1

More than 3 years have passed since last update.

PythonCGIでラズパイのGPIOを操作しよう

Posted at

前提

  • python -m http.server 8080 --cgiでCGIが実行可能
  • Apache2をインストール済み

Apache2の設定

GPIOを使うための設定

  • sudo usermod -aG gpio www-dataをしておく

解説

 先ほどのコマンドを入力せずに実行するとエラーは表示されないが、ラズパイに反応が現れない。そこでエラーログを確認してみる。
 less /var/log/apache2/error.logとして確認すると、RuntimeError: No access to /dev/mem. Try running as root!とエラーが表示されている。「ルートとして実行してみてください。」と書かれているので先ほどの設定でルート権限を与えた。www-dataというのはApache2のユーザ名である。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1