抱歉,这个问题是新手问的,我刚刚买了一个 VPS,安装了 Python,并迁移了我的网站。一切正常,但当我尝试运行脚本(在 /cgi-bin/ 中)时,出现 500 内部服务器错误。我可以在哪里找到此错误日志?
我的信息是:
Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at
提前致谢!
答案1
/etc/httpd/logs/
答案2
检查解释器是否已添加到脚本中,添加
#!/usr/bin/python
或#!/usr/bin/env python
如果有的话,请检查日志
/var/log/apache2
以了解详细错误。我发现日志中缺少 pip 包。ubuntu@ip:/var/log/apache2$ ll 总计 36 drwxr-x--- 2 root adm 4096 十一月 6 18:08 ./ drwxrwxr-x 12 root syslog 4096 十一月 6 18:57 ../ -rw-r----- 1 root adm 9543 十一月 6 21:36 access.log -rw-r----- 1 root adm 15941 十一月 6 21:35 error.log -rw-r----- 1 root adm 0 十一月 6 18:08 other_vhosts_access.log ubuntu@ip:/var/log/apache2$
访问脚本示例tail -f http://<ip>/cgi-bin/test-db.py
[Sun Nov 06 21:35:18.928560 2022] [cgi:error] [pid 8303:tid 139738648380992] [client 49.207.201.90:5556] AH01215: Traceback (most recent call last):: /usr/lib/cgi-bin/test-db.py
[Sun Nov 06 21:35:18.928839 2022] [cgi:error] [pid 8303:tid 139738648380992] [client 49.207.201.90:5556] AH01215: File "/usr/lib/cgi-bin/test-db.py", line 3, in <module>: /usr/lib/cgi-bin/test-db.py
[Sun Nov 06 21:35:18.929051 2022] [cgi:error] [pid 8303:tid 139738648380992] [client 49.207.201.90:5556] AH01215: import pymysql: /usr/lib/cgi-bin/test-db.py
[Sun Nov 06 21:35:18.929213 2022] [cgi:error] [pid 8303:tid 139738648380992] [client 49.207.201.90:5556] AH01215: ModuleNotFoundError: No module named 'pymysql': /usr/lib/cgi-bin/test-db.py
[Sun Nov 06 21:35:18.941377 2022] [cgi:error] [pid 8303:tid 139738648380992] [client 49.207.201.90:5556] End of script output before headers: test-db.py