doujie9252 2017-04-20 08:31
浏览 28

PHP长期运行脚本替代? [重复]

This question already has an answer here:

I'm trying to download a file from a remote server with file_put_contents. This script is called via ajax. The problem i'm having is the script timeout when the file is large e.g. (500mb). I get 504 Gateway Timeout - nginx

download.php $destination = "/home/mywebsite/public_html/wp-content/channels/videos/test.mp4";

    $link = "http://www.example.com/videos/movie.mp4"; //500mb
    $result = file_put_contents($destination, fopen($link, 'r'));

I'm using dedicated hosting. I've changed my php.ini and confirmed in phpinfo();

max_execution_time 7200 max_input_time 7200 max_input_vars 1000 memory_limit -1 output_buffering 4096 post_max_size 1200M upload_max_filesize 1000M

This script keeps timing out. Is there another solution how do i solve? When i check the directory the file is successfully downloaded but the page times out. So i can't return any data via ajax.

How do i solve?

</div>
  • 写回答

2条回答 默认 最新

  • duanpacan9388 2017-04-20 08:35
    关注

    You should also change nginx fcgi timeout values. PHP script continues executing but your connection between nginx and PHP timeouts.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP