dongshi6969 2017-07-06 14:59
浏览 54

服务器的时区和日期向后变化后,PHP文件的更改不会产生任何影响

I found a very weird bug...

I changed a PHP file on my VPS and added a debug line that echoes a string. After it, I changed my server's timezone and also the date (both were wrong). Now when I modify that file, nothing is changed on the live site.

I've double-checked if I wasn't writing on the wrong file/dir, and have done some testing to be sure I'm on the right file:

  • Added another file on the same folder and tried accessing it from the live site [worked, ok]
  • Modified that file and accessed again [worked, ok]
  • Modified other files that already existed on the same folder [didn't work, the changes didn't take any effect]
  • Added die("test"); at the top of my index.php file so my site would stop working [didn't work, the entire site worked normally without any "test" die o.O ]
  • Renamed index.php to ofaiwjefiow.php (of course this filename isn't on my .htaccess's DirectoryIndex) [didn't work, the entire site continued working normally as if there was an index.php file - i checked if there are other possible directory indexes such as index.html but there weren't].
  • With the original index.php renamed, added another index.php file containing only one string "test" and nothing more [the old index.php file continued being executed - of course I didn't include it]
  • Renamed this "test" index.php to index.html [it worked, so it looks like this issue is only with .php files]
  • Checked if some native caching such as APC was enabled [it wasn't - also, my application is coded from scratch, too simple, uses standard PHP/no frameworks, and didn't need a caching system so I didn't code it nor used any framework or library that could create a cache - I didn't even use Composer]
  • Tried touching the files [their last modified date is ok, showing the current time, however it also produced any change]
  • Browser cache clearing, tried also on other browsers where I didn't access this site before [same thing]
  • Restarted Apache [same thing]

My bet is that some Unix caching that I am not aware of (nor installed it) is keeping the old files since they 'exist since the future' (because my system clock was wrongfully set to afterwards) and my recent changes happened 'before' (according to the system clock) those wrong ones. I just don't know how to find and disable/refresh it...

Server: Ubuntu, Apache, PHP 5

  • 写回答

1条回答 默认 最新

  • douzhanshen0657 2018-02-16 21:52
    关注

    I had the same issue. What worked for me was to restart PHP after changing the system clock. From command line (Linux distributions), you can use:

    sudo service {php service name} restart
    

    or

    sudo systemctl restart {php service name}
    

    Replace {php service name} with your PHP service name, e.g. service php7.1-fpm restart. If you don't know the service name, one way to list all service names (I'm sure this depends on your version of Linux, works for me in Ubuntu 16.04): service --status-all

    评论

报告相同问题?

悬赏问题

  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL