我在Heroku上有一个使用会话的Symfony应用程序(例如,让用户登录)。
我已经配置了memcachier(heroku addons
命令的输出):
Add-on Plan Price
───────────────────────────────── ──── ─────
memcachier (memcachier-flat-XXXX) dev free
我还在项目的根目录中创建了文件.user.ini
,其中包含以下内容:
session.save_handler=memcached
memcached.sess_binary=1
session.save_path="PERSISTENT=myapp_session ${MEMCACHIER_SERVERS}"
memcached.sess_sasl_username=${MEMCACHIER_USERNAME}
memcached.sess_sasl_password=${MEMCACHIER_PASSWORD}
此外,我已为composer.json
添加ext-memcached
此要求:
"require": {
"php": ">=5.3.9",
"ext-memcached" : "*",
"symfony/symfony": "2.7.*",
所以当我通过heroku run bash
登录实例并检查是否安装了memcahed模块时 - 一切似乎都很好(通过nginx执行phpinfo()并且php5-fpm返回相同的配置值)
~ $ php -i | grep memcache
/app/.heroku/php/etc/php/conf.d/110-ext-memcached.ini
memcached
memcached support => enabled
libmemcached version => 1.0.18
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.serializer => php => php
memcached.sess_binary => 0 => 0
memcached.sess_connect_timeout => 1000 => 1000
memcached.sess_consistent_hash => 0 => 0
memcached.sess_lock_expire => 0 => 0
memcached.sess_lock_max_wait => 0 => 0
memcached.sess_lock_wait => 150000 => 150000
memcached.sess_locking => 1 => 1
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_prefix => memc.sess.key. => memc.sess.key.
memcached.sess_randomize_replica_read => 0 => 0
memcached.sess_remove_failed => 0 => 0
memcached.sess_sasl_password => no value => no value
memcached.sess_sasl_username => no value => no value
memcached.store_retry_count => 2 => 2
memcached.use_sasl => 1 => 1
Registered save handlers => files user memcached
然而,当通过heroku run bash
检查实例并运行php -i | grep session
时,您可以看到 session.save_handler 仍然是files
,尽管在.user.ini
中进行了配置{ {1}}
session.save_handler = memcached
所以我想知道为什么session
session.auto_start => Off => Off
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => no value => no value
session.cookie_httponly => Off => Off
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_secure => Off => Off
session.entropy_file => /dev/urandom => /dev/urandom
session.entropy_length => 0 => 0
session.gc_divisor => 1000 => 1000
session.gc_maxlifetime => 1440 => 1440
session.gc_probability => 1 => 1
session.hash_bits_per_character => 5 => 5
session.hash_function => 0 => 0
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => files => files
^^^^^^^^^^^^^^ WTF ???
session.save_path => no value => no value
session.serialize_handler => php => php
session.upload_progress.cleanup => On => On
session.upload_progress.enabled => On => On
session.upload_progress.freq => 1% => 1%
session.upload_progress.min_freq => 1 => 1
session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix => upload_progress_ => upload_progress_
session.use_cookies => On => On
session.use_only_cookies => On => On
session.use_strict_mode => Off => Off
session.use_trans_sid => 0 => 0
配置不能在真正的.user.ini
配置中生效?
答案 0 :(得分:3)
这是一种常见的误解。 heroku run bash
会旋转您项目的单独实例。当你对项目进行实际的http或https调用时,“.user.ini”会有条件地应用,因为服务器(在你的情况下是nginx)正在尝试访问的文件(web.php)。基本上“.user.ini”不适用于全球,也不适用。