Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changes to php file doesn't reflect unless I restart php-fpm on Ubuntu

Tags:

php

ubuntu

I have a Ubuntu and a centos server. On the centos server, whenever I change php files, they reflect immediately, but on Ubuntu, I have to restart php-fpm to make them reflect.

I didn't find anything relevant.

Anyone has similar experience?

like image 578
user1149293 Avatar asked May 24 '15 01:05

user1149293


2 Answers

  • What version of php on which version of ubuntu ?
  • Do you have any reference of opcache.enable=1, somewhere in your php config maybe (/etc/php5/fpm/conf.d/) ?

In a temporary php file, put something like this (don't forget to remove it afterward):

   <?php
   phpinfo();

On recent PHP version (5.5+), search for Zend OPcache section and see if it's active or not It might be enabled in . If so, take a look to opcache doc to configure it properly (according the dic, opcache.revalidate_freq to 0 for a check on each request). https://php.net/manual/fr/opcache.configuration.php#ini.opcache.revalidate-freq

Another cause might be php apc (for php 5.4 and lower).

like image 67
Damien Avatar answered Oct 21 '22 09:10

Damien


My search for same thing landed me here. Opcache is enabled. And for the setting mentioned in above link to (not English) PHP docs, I only caught that "0 will result in OPcache checking for updates on every request. "

However, I didn't initially catch the next line. So, in an effort to save others a few extra minutes, here's the info:

You'll need to edit these two settings in your either your php.ini or ext-NN-opcache.ini (auto include) and then restart php-fpm with service php-fpm restart in order to see changes.

; after how many seconds should code/file be checked for changes (expire)

opcache.revalidate_freq=5

; If this is off, the above does not matter. won't be checked. (no expire)

opcache.validate_timestamps=1

Here's the English version link: https://secure.php.net/manual/en/opcache.configuration.php#ini.opcache.revalidate-freq

like image 43
Chris Avatar answered Oct 21 '22 10:10

Chris