PHP and 2GB Size Files

Today, I was trying to open a 2.5 GB file in PHP. PHP was unable to open the file on my 32 bit machine, but it worked great on my 64 bit machine. Running the script on my 64 bit machine wasn’t an option, so it was time to do some digging into the problem.

I know that there are a lot of memory issues when crossing the 2 GB barrier due to design limitations with 32 bit systems. After some digging, I found that you need to enable what a lot of people call “Large File Support” or LFS. At first, I only saw references to it as LFS, so I thought…. Linux From Scratch, but I guess I was wrong.

To add the Large File System support, add the following to your configure line.

CFLAGS=”-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64″

In my case, it looks like…

CFLAGS=”-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64″ ./configure
–with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql
–with-libxml-dir=/usr/local/

I found the answer on PHP.net right here.

-Kim

Leave a Reply

Your email address will not be published. Required fields are marked *