Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Help configuring php to allow downloads greater then 2GB. 32 bit OS
New on LowEndTalk? Please Register and read our Community Rules.

Help configuring php to allow downloads greater then 2GB. 32 bit OS

PcJamesyPcJamesy Member
edited May 2013 in Help

I recently got a new vps to put owncloud on. The vps is running unbuntu with apache2 and php5 and has 256 MB or ram. I'm able to download the first 2GB of any file but nothing larger then that. From reading it's a 32 bit issues but i have no way to move from 32 bit to 64.

If anyone has any ideas of what to do to increase the download limit it would be appreciated.




    Can't be fixed, it is a limit with PHP and 32 bit systems

  • AdducAdduc Member

    The owncloud issue mentioned is concerned with file uploads.

    Regarding downloads, readfile should in theory work for you.

    If not, you'll have to read/flush file manually using something like this:

    $file = @fopen($file_path,"rb");
    while(!feof($file)) {
        print(@fread($file, 1024*8));

    If you're running Nginx with gzip or any buffering, you may have to toss out a few headers to prevent caching before hand, although my Google-fu eludes me at the moment.

    DevOp based out of Chicago Somewhat knowledgeable about php.
  • @rldowling03 no it's a limit with 32-bit integers

    ..technically speaking

  • rds100rds100 Member

    Even apache on 32bit systems doesn't allow downloading files larger than 2GB, php doesn't need to be involved at all.


  • DaosmbDaosmb Member

    Do you need to use a download manager? If you are downloading through any web browser it might download the file as one piece so over 2 GB thing limitation can take place, while download managers splits the file and download it in parallel in 2, 3, 4, 5 or whatever you've specified as number of threads.

  • rds100rds100 Member

    apache 32bit simply can't read past 2GB of a file, no matter if you use download manager or not.
    It's a limitation of the system calls used, which take 32bit signed integer as parameter for the file offset. The 32bit signed integer can't be more than 2^31-1 which is just a byte smaller than 2GB.


  • AdducAdduc Member

    That's not true @rds100. I was just able to download a 4GB file straight from Apache running on a 32-bit version of CentOS 6.

    DevOp based out of Chicago Somewhat knowledgeable about php.
  • rds100rds100 Member

    @Adduc yes, i was probably wrong, i remembered something from long time ago and didn't test with a recent apache version. Apache 2.0 and below has such limitation, couldn't serve a file larger than 2GB.

    It seems in apache 2.1 and later a workaround was implemented and they support larger files.


  • Thanks for trying guys. I contacted the provider and even though they didn't have a 64bit option listed they installed one for me. On the 64bit version downloads are working fine.

Sign In or Register to comment.