6

I'm developing on a CentOS6 server with Apache and PHP. When I make a change to a PHP file (and save) it appears that apache is not reading the changed file - it's still processing my old .php file. After 5-10 minutes it will start to use the new file.

Can someone tell me how to force Apache to immediately pickup the changed .php files?


UPDATE: I moved the files onto the apache server and the problem remains (this is not an NFS issue). So it seems that Apache is just not reading in the changed files for several minutes Confused...

5
  • Please provide the mount options from /etc/fstab, just in case. Feb 13, 2015 at 19:04
  • I mounted from the command line, but used "lookupcache=none" as only option
    – TSG
    Feb 13, 2015 at 19:37
  • path/to/bin/apachectl graceful does not ready the changes immediately?
    – devnull
    Feb 13, 2015 at 20:24
  • Just in case: I had a similar issue, my conclusion lead to browser's cache as culprit. have you check with different browser ?
    – Archemar
    Feb 14, 2015 at 9:25
  • I have a similar problem with Chrome, even if I use Ctrl-Shift-Del to clear the cache. My file is updated on the server but won't show it. sdsolarblog.com/montage/show.html
    – SDsolar
    Oct 16, 2017 at 3:02

5 Answers 5

10

Maybe I had the same problem with you and it was because opcache configuration on php.ini. So I set revalidate frequency to 0

opcache.revalidate_freq=0

or disabled opcache

opcache.enable=0

Remember to restart Apache server afterwards.

1

I had a similar problem on my development machine where updates to PHP code are not reflecting immediately. I resolved the issue by editing php.ini opcache settings and setting the directive as

opcache.enable=0
0

Apache does not activelly monitor changes on the PHP andother configuration files. You need to tell the service to reload the changes.

# service httpd reload

or stopping and starting the server altogether:

# service httpd restart

On a different note, you can see when the server reloaded your data by enabling mod_status on your httpd.conf file (usually on /etc/httpd/conf/httpd.conf) appending or un-commenting the following:

<Location /server-status>
SetHandler server-status

Order Deny,Allow
Deny from all
Allow from .example.com
</Location>

Where "Allow from" should be followed by your domain, IP, localhost (the last one if you are developing on the same machine) or a combination of them all separated by spaces.

Then, if you use the newly created special handler for the location /server-status (append this at the end of your URL server, like in http://www.server.com/server-status) and you'll see a lot of information regarding the running status of your Apache server, including information about the last time it was configured.

2
  • 2
    I am not sure @Michelle refer to configuration file, but just to plain foo.php
    – Archemar
    Feb 14, 2015 at 9:21
  • I'd bet this would work except I am on a hosting service so can't do this.
    – SDsolar
    Oct 16, 2017 at 3:01
0

php opcache helps to load the site fast. so try this way if you aware about the site speed and php performance

opcache provides a way to blacklist files so you can use this to include files that you will be changed frequently.

Instead of disabling opcache or reducing it's frequency to check files, add your frequently changing files list to opcache*.blacklist where it exists at /etc/php.d/ in cent os 7 (for an example, mine was autoload files in zend framework)

you have an explanatory in this file,

; The blacklist file is a text file that holds the names of files
; that should not be accelerated. The file format is to add each filename
; to a new line. The filename may be a full path or just a file prefix
; (i.e., /var/www/x  blacklists all the files and directories in /var/www
; that start with 'x'). Line starting with a ; are ignored (comments).
; Files are usually triggered by one of the following three reasons:
; 1) Directories that contain auto generated code, like Smarty or ZFW cache.
; 2) Code that does not work well when accelerated, due to some delayed
;    compile time evaluation.
; 3) Code that triggers an OPcache bug.

thank you

-1

I had the same probleme and it was because of APC config in my php.ini

so I just disabled it:

apc.enable=0 

and I use apcu instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.