- 環境
Mac OSX 10.11.6 El Capitan
MAMP 4.0.1
Apache/2.2.31
Python 3.5.2
- やりたい事
Apache上でPythonをcgiとして使いたい。
- 困っていること
500 Internal Server Errorが表示される
- やった事
MAMP 4.0.1 をインストールし、
httpd.conf
の
AddHandler cgi-script .cgi .pl
を
AddHandler cgi-script .cgi .pl .py
に書き換え、Apacheを再起動しました。
/Applications/MAMP/htdocs/python/index.py
Python
1#!/usr/bin/env python 2# -*- coding: UTF-8 -*- 3 4# enable debugging 5import cgitb 6cgitb.enable() 7 8print("Content-Type: text/plain;charset=utf-8") 9print() 10 11print("Hello World!")
というスクリプトを作成し、ブラウザで
http://localhost/python/index.py
を確認すると
500 Internal Server Error
になります。
ターミナルで
bash
1$ python /Applications/MAMP/htdocs/python/index.py
を実行すると
Content-Type: text/plain;charset=utf-8 Hello World!
と表示されます。
pythonのバージョンは
ターミナルでは
Python 3.5.2
ですが、
phpinfo();
では
Python/2.7.12
と表示されています。
index.py
の1行目を
Python
1#!/usr/bin/python2.7
に変えても結果は同じでした。
何がいけないのでしょう?

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/09/08 03:24