Raspberry piに搭載されているApache2にてpythonのcgiモジュールの動かしたい
…簡単に言うと、pythonのcgiモジュールで、「Hello World!」を出したいというイメージです。
◆仕様
Raspberry pi 3 (Raspbian GNU/Linux 9.4 (stretch))
Apache/2.4.25 (Raspbian)
◆参考サイト
http://min117.hatenablog.com/entry/2017/07/30/113005
上記参考サイトを順に実行していったのですが、
http://(IPアドレス)/cgi-bin/cgi.py
を実行すると、以下の500番エラーが出てしまいます。
それを直したいです。
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log.
◆私が実施した設定(参考サイトをご覧になりながらお願いします)
基本的には、参考サイトに準じていますが、以下設定を初期のままでいいと思い変えてないです。
それによる不都合なのかもしれません。
Webアクセスした時に最初に表示されるフォルダ(DocumentRoot)を変更(していません)
(参考サイト)/home/pi/Desktop/public_html/ (私の設定)/var/www/html/
/etc/apache2/sites-available/000-default.conf
(参考サイトの設定) DocumentRoot /home/pi/Desktop/public_html <Directory "/home/pi/Desktop/public_html"> Options +Indexes +FollowSymLinks +MultiViews +ExecCGI AllowOverride All Require all granted </Directory> (私の設定) DocumentRoot /var/www/html <Directory "/var/www/html"> Options +Indexes +FollowSymLinks +MultiViews +ExecCGI AllowOverride All Require all granted </Directory>
/etc/apache2/conf-available/serve-cgi-bin.conf
(参考サイトの設定) ScriptAlias /cgi-bin/ /home/pi/Desktop/public_html/cgi-bin/ <Directory "/home/pi/Desktop/public_html/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Require all granted </Directory> (私の設定) ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Require all granted </Directory>
/usr/lib/cgi-bin/にあるpythonファイル(cgi.py)は、以下の通り
python
1#!/usr/bin/python3 2# -*- coding: utf-8 -*- 3 4import cgi 5 6print "Content-Type:text/html\n\n" 7print "Hello World!"; 8
そして、疑問なのですが、なぜ、ディレクトリをわざわざ、/home/pi/Desktop/public_htmlにしなければならないのでしょうか?/usr/lib/cgi-bin/だとほかのプログラムを動かすのに不都合だからでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。