Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 9th January 2012, 17:09
cbj4074 cbj4074 is offline
Senior Member
 
Join Date: Nov 2010
Posts: 388
Thanks: 28
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
  #2  
Old 9th January 2012, 18:15
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 35,466
Thanks: 813
Thanked 5,253 Times in 4,119 Posts
Default

Do you use some kind of binary cache like eaccelerator, xcache or similar? If yes, have you tried to disable it.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
The Following User Says Thank You to till For This Useful Post:
cbj4074 (9th January 2012)
  #3  
Old 9th January 2012, 21:54
cbj4074 cbj4074 is offline
Senior Member
 
Join Date: Nov 2010
Posts: 388
Thanks: 28
Thanked 58 Times in 50 Posts
Default

Hmm, now that you mention it, APC ( http://php.net/manual/en/book.apc.php ) is installed and enabled on this server.

I bet that's the problem.

APC was installed to enable upload progress bar functionality.

Now that we know that the problem is related to APC, it was easy to find people reporting similar problems:

https://bugs.php.net/bug.php?id=57203

Maybe this is simply a bug, or maybe APC can be configured to allow for this kind of "building" behavior.

Thanks for the help, Till!
Reply With Quote
  #4  
Old 9th January 2012, 23:13
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 35,466
Thanks: 813
Thanked 5,253 Times in 4,119 Posts
Default

I use xcache on my servers instead of apc. Maybe it works nbetter for you as well.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #5  
Old 10th January 2012, 22:18
cbj4074 cbj4074 is offline
Senior Member
 
Join Date: Nov 2010
Posts: 388
Thanks: 28
Thanked 58 Times in 50 Posts
 
Default

Great, thanks, I will look into xcache.

In the meantime, I think I found the configuration directive to change:

apc.stat_ctime (integer):

Quote:
Verification with ctime will avoid problems caused by programs such as svn or rsync by making sure inodes haven't changed since the last stat. APC will normally only check mtime.
This sounds like exactly the issue I've been grappling with. I'll post back once I've had a chance to see how the server response with apc.stat_ctime set to On.
Reply With Quote
Reply

Bookmarks

Tags
apache, error, modphp, sporadic

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ubuntu and nginx delgado2061 Installation/Configuration 0 27th November 2011 23:36
rkhunter warnings esezako General 7 27th September 2011 07:28
Can't receive mails baicunko Server Operation 12 3rd August 2011 22:02
Hacked server Captain Installation/Configuration 8 23rd December 2010 10:39
Unable to install ISPConfig bdonecker Installation/Configuration 21 26th May 2009 08:20


All times are GMT +2. The time now is 08:21.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.