Не зная многого о том, чего вы пытаетесь достичь, я бы выбрал базовое решение http, запустив простой http-сервер с python
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
.... do something with the http request and send the response
Тогда сценарий php может просто выполнить GET / POST/ etc .. запросить непосредственно к python и получить ответы http, например, через cURL:
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "localhost");
// set port
curl_setopt($ch, CURLOPT_PORT, 8000);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
Конечно, это простая заглушка, и ее нужно немного подправить, но она должна дать вамотправная точка.