tags:

views:

193

answers:

3

Hello all,

A very strange thing is happening. I am running a script on a new server (it works on my current server and laptop).

The strange thing is that I only get it to (sort of) work when I increase memory limit to 1024M (!). It is extracting a large zip file and going through the files, so I thought it was normal. Instead of this script terminating or ending with errors. I get an error from my browser:

The server at www.localhost.com is taking too long to respond.

Localhost.com? The web server is just localhost:9090 and I can see Apache is still running. Maybe Apache crashes momentarily and it can't find the server? But nothing about apache crashing in the log files.

This isn't a server issue, its more to do with my PHP script and memory usage I think, so no need to move to server fault.

What could be the problem? How can I narrow do the cause, I am at loss here!

The server is a windows server running Apache 2.2 with PHP version 5.3.2. May laptop and the other working server are running version 5.3.0 and 5.3.1 for PHP.

Thanks all for any help

+1  A: 

Ensure that,

ini_set('display_errors','On');
ini_set('error_reporting',E_ALL);
ini_set('max_execution_time', 180);
ini_set('memory_limit','1024MB' );

I'd pop this in the top of the script and see what comes out. It should show you errors and the like.

The other thing, have you checked fopen and the path of the file which it's loading?

Abs said,

check files being zipped up can be zipped by PHP (permissions especially on a Windows OS with multi users)

DavidYell
Interesting, I placed the above at the top of my script and came back with a blank page straight away?! There should be quotes for '`1024mb'`. Just checking all file paths for the hundredth time!
Abs
All file paths are correct as well. It doesn't even show an error!
Abs
Oops, sorry. How very odd. Have you tried backing up your apache httpd.conf and replacing it with a vanilla one and then trying? Just to eliminate the server as a problem? Are you sure `9090` is a free port?
DavidYell
@David, yes 9090 is a free port. I have found the problem now though, the files I was trying zip up with my PHP script had an access file that was open and for some reason it was being denied to zip that up. I thought php_zip only tried to zip things up in read only mode and this was probably being refused. So I removed that file by closing the Access database being used by another user and it worked!
Abs
@David can you edit your question to include what I said above i.e. check files being zipped up can be zipped by PHP (permissions especially on a Windows OS with multi users) and I will close this question using your answer. This is a weird case that others need to know about to eliminate frustration.
Abs
A: 

Somehow your system's munged up and isn't treating localhost as the local 127.0.0.1 address. Is your hosts file properly configured? This is most likely why you're getting the "too long to respond" error:

marc@panic:~$ host www.localhost.com
www.localhost.com has address 64.99.64.32

marc@panic:~$ wget www.localhost.com
--2010-08-03 22:41:05--  http://www.localhost.com/
Resolving www.localhost.com... 64.99.64.32
Connecting to www.localhost.com|64.99.64.32|:80... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying.

www.localhost.com is full valid hostname as far as the DNS system is concerned.

Marc B
A: 

I am not a php guru by any means but are you writing the extracted files to a temporary local storage location that is within the scope of the application? Because if you are not then I think what is happening is that the application is storing the zip file and extracted files in memory and then is attempting to read them. So if it is a large zip and/or the extracted files are large that would introduce a huge amount of overhead on top of the overhead introduced by your read and processing actions.

So if you are not already I would extracted the files and write them to disk in their own folder, dispose of the zip file at this point, and then iterate over the files in your newly created directory and perform whatever actions you need to on them.

antonlavey