问题原文
原帖链接 · nosh · CC BY-SA 4.0
(I'm trying to deploy an open source php project to nginx. The project itself does not matter.)
I need to set date.timezone to my local timezone because the project uses a global setting.
I found a line in my php.ini (at /etc/php/7.0/fpm/php.ini for debian) file but because I did not want to change the global setting, I created a new ini file in the fpm/conf.d/ directory with the line:
date.timezone = ('Europe/Berlin')
This is one of the supported time zones as documented here However when I look at my php info, the timezone reflects in both "Local Value" as well as "Master Value".
Can I have it so that only this one php project has the timezone set while the global remains at the default UTC?
已采纳解答
原帖链接 · Esa Jokinen · CC BY-SA 4.0
The fpm/conf.d/ is scanned for additional .ini files, making it easier to separate configuration for example per module. Those are scanned for every FPM pool, i.e. it's a global configuration just like the php.ini.
You can override individual settings for a single pool in your fpm/pool.d/poolname.conf:
php_admin_value[date.timezone] = Europe/Berlin
Shortly on PHP FPM pools that allows using separate settings, resources & user (permissions):
The default pool is configured in
fpm/pool.d/www.conffor listening a UNIX socket:listen = /run/php/php7.2-fpm.sockAlso notice that it runs as the user
www-data(ornginx), having all its permissions.Nginx
server{}block passes PHP script to this socket for the PHP FPM pool to handle:location ~ \.php$ { fastcgi_pass unix:/run/php/php7.2-fpm.sock; # another fastcgi options }You can run the PHP of your single project as a separated user
mauticby creating an additional FPM pool, e.g.fpm/pool.d/mautic.conffor your Mautic project:[mautic] user = mautic group = mautic listen = /run/php/mautic.sock chdir = /var/www/mautic # or /home/mautic etc. listen.owner = www-data # or nginx(?) to let Nginx use the socket listen.group = www-data php_admin_value[date.timezone] = Europe/BerlinAnd naturally use this new
/run/php/mautic.sockin the relevant Nginx configuration.
The official documentation starts from where you should already know the basic idea, making it a bit hard for beginners. Luckily there are tutorials, or you could even enjoy watching a video.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
