PHP uses Redis

Source: Internet
Author: User
Tags php redis
PHP uses Redis


1.PHP installation Redis Extension:
Before we start using Redis in PHP, we need to make sure that we have the Redis service and PHP Redis driver installed, and that PHP is working properly on your machine.
Next let's install the PHP redis driver: Download the address: Https://github.com/nicolasff/phpredis.


/usr/local/php/bin/phpize #php安装后的路径
./configure--with-php-config=/usr/local/php/bin/php-config
Make && make install


2. Modify the php.ini file
Vi/usr/local/php/lib/php.ini


3. Add the following:
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
Extension=redis.so


4. Restart PHP-FPM or Apache after the installation is complete. Viewing phpinfo information, you can see the redis extension.




Use Connect to Redis service
<?php
Connecting to the local Redis service
$redis = new Redis ();
$redis->connect (' 127.0.0.1 ', 6379);
echo "Connection to server sucessfully";
To see if the service is running
echo "Server is running:" + $redis->ping ();
?>


From: http://www.redis.net.cn/tutorial/3526.html
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.