我个人不会使用PHP来传输视频。问题是,为了读取和流式传输一个大文件,而不是处理逻辑,必须锁定许多PHP进程。在此过程中,您还将有一个PHP超时。 相反,我会使用Sendfile模块: 您可以为web服务器、NGINX或其他任何东西安装Apache模块或其他类型的Sendfile模块。 在PHP中,您执行保护逻辑,只需发送一个HTTP头,表示希望Sendfile处理流媒体。通过这种方式,PHP代码停止运行,并将其发送到处理文件传输的web服务器。 比如: <?phpif (has_access_to_the_video($file)){ // Send the right HTTP headers. header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Content-type: ' . mime_content_type($file)); header('Content-Length: ' . filesize($file)); // Make sure you have X-Sendfile m