问题
I'm running an apache2 server on Ubuntu 18.04 with PHP running as FPM server. I want to use libfaketime
(https://github.com/wolfcw/libfaketime) to have a fake time for the server that I can set. I added the following lines to the /etc/apache2/envvars
file:
export FAKETIME="$(cat /var/www/.faketimerc)"
export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1"
The file /var/www/.faketimerc
contains the fake time I want to use. These settings lead to the right date in the header in the browser, but when I use the date
function in a PHP file, it returns the time of my machine and not the fake time. The problem seems to be that I have to setup FPM to use libfaketime
.
I tried to add both the variables from above to the /etc/environment
, but that broke my system. I added the following line to a new *.conf
file in the /etc/php/7.2/fpm/pool.d
directory:
env[FAKETIME] = "2019-12-03 12:00:00"
env[LD_PRELOAD] = "/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1"
But after that, my server didn't work anymore.
来源:https://stackoverflow.com/questions/59458394/fpm-setting-up-libfaketime