FPM - Setting up libfaketime

我们两清 提交于 2020-06-17 09:12:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!