Apache not reading changes to PHP files

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…

Asked By: TSG


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

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.

Answered By: Carlos Niebla

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


or disabled opcache


Remember to restart Apache server afterwards.

Answered By: Wilianto Indrawan

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

so I just disabled it:


and I use apcu instead.

Answered By: rivelbab

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

Answered By: Hungu

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

Answered By: Janaka R Rajapaksha

If you have php-fpm daemon running, you will need to do one more step for your php.ini changes to be recognized, just restarting apache is not enough.

On Linux:

sudo kill -USR2 PID

Specify the PID of the php-fpm main process. You can find that process ID by ps auxwwf | grep php.

My Amazon Drupal instance came with this php-fpm process running; took me a while to figure this out.

Answered By: Paul B
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.