500 internal server error

实验CGI脚本 输出CGI环境变量:

#!/usr/bin/python
# -*- coding:UTF-8 -*-
# filename:test.py

import os

print"Content-type :text/html"
print
print""
print"环境变量
"; print"
    " for key in os.environ.keys(): print"
  • %30s : %s
  • " % (key,os.environ[key]) print"
"

在浏览器中打开http://localhost/cgi-bin/test.py提示出现500 internal server error

处理:
查看错误日志/var/log/httpd/error_log

[Fri Mar 16 11:40:46.894709 2018] [http:error] [pid 15292] [client ::1:58978] AH02429: Response header name 'Content-type ' contains invalid characters, aborting request

显示含有无效字符
检查后发现Content-type后多了一个空格符
删除掉空格后正常


你可能感兴趣的:(500 internal server error)