windows server2016 + apache2.4 + cgi + python3.8 出现500服务器错误

在Windows Server 2016上配置Apache 2.4与CGI和Python 3.8时遇到500内部服务器错误。尝试通过调整权限、检查错误日志、确认解释器路径以及修复HTML格式问题进行故障排除。最终,问题定位为Python脚本中的代码错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Linux下一般是权限问题,windows这我设置成everyone全开

问题依旧

 

查看Apache错误日志error.log


[Tue Mar 03 10:06:33.115038 2020] [cgi:error] [pid 2484:tid 1048] (9)Bad file descriptor: [client ::1:55544] AH01222: don't know how to spawn child process: E:/Apache24/cgi-bin/hello.py

 网查,说是找不到解释器,检查windows的path,在cmd中运行脚本正常。

检查cgi-bin目录下的python脚本文件,删除#!C:\Users\Administrator\AppData\Local\Programs\Python\Python38\

问题依旧


[Tue Mar 03 10:06:33.036916 2020] [win32:error] [pid 2484:tid 1048] [client ::1:55544] AH02102: E:/Apache24/cgi-bin/hello.py is not executable; ensure interpreted scripts have "#!" or "'!" first line

发现需要加上python.exe 最终效果:

#!C:\Users\Administrator\AppData\Local\Programs\Python\Python38\

问题依旧,但是问题是HTML格式错误,也就是python程序运行了,只是我写的代码有问题。



[Tue Mar 03 10:09:05.824618 2020] [cgi:error] [pid 2484:tid 1048] [client ::1:55622] malformed header from script 'hello.p
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值