Mi antiguo servidor Apache CentOS 5 puede ejecutar CGI de secuencias de comandos Perl sin ningún problema.
# cat t1.cgi #!/usr/local/bin/perl use CGI; my $cgi = CGI->new(); print $cgi->header; print "Test\n"; # GET HTTP://www.example.com/cgi/t1.cgi TestLos scripts de python se pueden ejecutar bajo shell sin ningún problema:
# cat t2.cgi #!/usr/local/bin/python3 print("Content-Type: text/html\n") print("hello!") # python3 t2.cgi Content-Type: text/html hello!pero falló como un script cgi de python:
# GET http://www.example.com/cgi/t2.cgi <HTML> <HEAD><TITLE>An Error Occurred</TITLE></HEAD> <BODY> <H1>An Error Occurred</H1> 500 Internal Server Error </BODY> </HTML>Los registros de errores de Apache muestran que el error fue:
Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python Python runtime state: preinitialized Premature end of script headers: t2.cgi¡Cualquier idea será apreciada!
arreglado por
mknod -m 444 /dev/random chmod 444 /dev/urandommis viejos centos no tienen /dev/random, y el modo de archivo predeterminado para urandom era 600, solo lectura por root.