View Single Post
Old 9th January 2012, 18:09
cbj4074 cbj4074 is offline
Senior Member
Join Date: Nov 2010
Posts: 395
Thanks: 30
Thanked 58 Times in 50 Posts
Default Apache misreading PHP files after file and directory modifications

I have a shell script that I use to "build" a PHP application on a development server.

Some percentage of the time, this build process causes Apache to interpret PHP files incorrectly.

In particular, I see error message that make absolutely no sense, such as "Class XYZ cannot be redeclared in file.php", even though the class in question is declared only once.

Another common error message is that a given file that is require()d is missing, even though the file is, in fact, present on the filesystem.

The only way I've been able to fix these problems when they occur is to restart Apache. As soon as I restart Apache, all of the errors disappear and the website/application functions as expected.

Because restarting Apache fixes the problem(s), Apache seems to be at fault.

Does anyone know if Apache "caches" files in some manner when running under ModPHP? I can't think of any other reason for this behavior.

It seems absurd that Apache would malfunction when files are added/deleted/moved on the filesystem, as any shared hosting environment would be plagued by such an issue.

The build script that I'm using performs the following actions:

1.) Delete all contents in website's document root.

2.) Export SVN repository contents to website's document root.

3.) Copy configuration files (not stored in SVN repo) into place.

4.) Copy .htaccess.txt to website document root and rename to .htaccess.

5.) Reset permissions on website document root (a series of chown and chmod commands).

The website in question is running under ModPHP.

I thought about changing the PHP mode for this website to Fast-CGI and seeing if the problem still occurs, but this will take considerable effort on my part, so I figured that I'd ask here first.

Thank you for any insights.
Reply With Quote
Sponsored Links