Run python on windows apache

From LemonWiki共筆
Revision as of 12:32, 11 December 2017 by Planetoid (talk | contribs) (Created page with "Run python on Windows/Apache == Troubleshooting == === Error message: End of script output before headers: python_script.py (Server 500 error) === # 檢查 Apache 設定步...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Run python on Windows/Apache

Troubleshooting

Error message: End of script output before headers: python_script.py (Server 500 error)

  1. 檢查 Apache 設定步驟 Barlos Blog 部落格: 在 Windows 下安裝 Apache + Python
    • Apache 設定檔對應的資料夾 Options 有加上ExecCGI 該行設定範例 Options Indexes FollowSymLinks ExecCGI
    • Apache 設定檔 AddHandler 部分有加上.py 該行設定範例 AddHandler cgi-script .cgi .py
  2. 檢查 Python 程式第一行的宣告 #!C:/Python33/python 但是因為 Python 版本可能更新,需要檢查版號是否正確。例如宣告 #!C:/Python33/python 代表 C:\Python33\python.exe 檔案需要存在。
  3. 檢查 Python 程式是否有錯誤
    • 例如程式碼使用了 package,但是伺服器環境並未安裝該 package