Linux in PHP Install Redis expansion module and test

Source: Internet
Author: User
Tags redis install redis

Take Linux for example, first download PHP expansion module, address Ps://github.com/nicolasff/phpredis ">https://github.com/nicolasff/phpredis, After the download completes the decompression operation first, tar zxvf phpredis.tar.gz
CD phpredis-master/
/usr/local/webserver/php/bin/phpize
./configure--with-php-config=/usr/local/webserver/php/bin/php-config
Make
Make install
Vi/usr/local/webserver/php/etc/php.ini
Extension = redis.so
Restart Apache or PHP-FPM

Check out phpinfo should see Redis extension
Windows Redis extended Download Address https://github.com/nicolasff/phpredis/downloads, select the corresponding version of the download can be.

After you set up your PHP extensions, write code to test it:

$redis = new Redis ();
$redis->connect (' localhost ', 6379);
$redis->set (' key ', ' Zhangsan '); Setting values
$res = $redis->get (' key ');
Echo $res;
$id = $redis->incr (' id ')/self-increasing
$redis->hmset ($id, Array (' User ' => ' zhangsan ', ' email ' => ' addd@ff.com '));
Print_r ($redis->hgetall (' 2 '));

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.