简体   繁体   中英

Cannot find save handler 'redis'

I am running a PHP 5.4 hosted Web App on Azure. To manage session handling I have configured a Redis cache instance on Azure.

I have set the session save path & handler:

session.save_handler = redis
session.save_path = "tcp://kbcache.redis.cache.windows.net:6379?auth=***"

I have also configured the Redis extensions:

PHP_EXTENSIONS  bin\php_igbinary.dll
APPSETTING_PHP_EXTENSIONS   bin\php_igbinary.dll
PHP_EXTENSIONS02    bin\php_redis.dll
APPSETTING_PHP_EXTENSIONS02 bin\php_redis.dll

However when I browse to my website I receive the message:

Warning: session_start(): Cannot find save handler 'redis' - session startup failed in D:\\home\\site\\wwwroot\\index.php(22) : eval()'d code on line 2

What am I missing?

[Update Pre post]

When deployed PHP project, we need enable extensions on Azure. Please see my website folder structure:

在此处输入图片说明

I copied the DLL files into folder named ext . And those dlls' version should be VC9 and non-thread-safe (nts) compatible.

在此处输入图片说明

And I created a extension.ini into folder name ini . The content as following :

extension=d:\home\site\ext\php_igbinary.dll
extension=d:\home\site\ext\php_redis.dll
zend_extension=d:\home\site\ext\php_xdebug-2.3.3-5.4-vc9-x86_64.dll
session.save_handler = redis
session.save_path = "tcp://**.redis.cache.windows.net:6379?auth=**

At last, I add the "PHP_INI_SCAN_DIR" Configurtation Panel on Azure portal:

在此处输入图片说明

It works for me.

Actually, I tried PHPRedis extension on my environment, it works fine.

Form your description, I think you made configuration of Redis extensions complicated.

I followed those steps:

1.Switch to PHP version 5.4

2.Download PHPRedis extension form this page . Since I used PHP which version is version 5.4 TS , I downloaded phpredis_5.4_vc9_ts

3.After unzipped the download file, Please copy those DLL file into your PHP ext folder. It seems that you need pay attention to this point.

Add this code into your PHP.ini file

extension=php_igbinary.dll
extension=php_redis.dll

session.save_handler = redis
session.save_path = "tcp://**.redis.cache.windows.net:6379?auth=**

4.Create a Page and test Redis Code:

$redis=new Redis();
$redis->pconnect('tcp://**.redis.cache.windows.net', 6379);
$redis->auth('**+**=');
$redis->set('key', 'hello '); 
$redis->append('key', 'world '); 
echo $redis->get('key');

had similar issues. make sure redis dll file is there and enabled in php.ini also make sure that redis folder has full write permissions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM