Overview

This topic describes how to use apsaradb for Redis to cache PHP session variables.

 

Detailed information

  1. Run the following commands in sequence to install the phpredis extension package:
    wget https://github.com/nicolasff/phpredis/archive/master.zip
    unzip master.zip 
    cd phpredis-master
    /data/apps/php5.5.0/bin/phpize 
    ./configure -with-php-config=/data/apps/php5.5.0/bin/php-config
    make
    make install
    Note: the paths of phpize and php-config are subject to the actual situation.
  2. Modify the following parameters in the php.ini file:
    extension = redis.so
    session.save_handler = redis
    session.save_path = "tcp:// The connection address of your apsaradb for redis instance? auth=the password of the apsaradb for redis instance"
    A similar output is displayed.
  3. Restart the web service after the configuration.
  4. Compile a PHP session generation page to check whether the parameters are saved to apsaradb for Redis. The following figure shows the content of test.php.
  5. Through execution php test.php command parse the PHP page to verify that the settings are saved to apsaradb for Redis.

 

Applicable to

  • Apsaradb for Redis