redis installation and php redis extension

WBOY
Release: 2016-07-29 09:08:30
Original
822 people have browsed it
1. Install redis

cd /usr/local/src
tar zxvf redis-2.8.20.tar.gz
# Copy to the /usr/local/redis folder
cp -r redis-2.8.20 /usr /local/redis
cd /usr/local/redis
make && make install

2. Start redis

cd /usr/local/redis/src
./redis-server

3. PHP install redis extension

cd /usr/local/src
tar zxvf phpredis-2.2.4.tar.gz
cd phpredis-2.2.4
/usr/local/php/bin/phpize
./configure --with-php-c/local /php/bin/php-config
make
make install

Record the path where the extension file is located, mine is:
/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
4. Enable redis extension
vim /usr/local/php/etc/php.ini
Add the following content at the end of php.ini
extension=/usr/local/php/lib/php/extensions/no-debug-non -zts-20121212/redis.so
After restarting the server, you can see the relevant information of the redis extension in phpinfo() and the installation is successful
5. Test

vim redis.php

<?php $config = array(
        &#39;host&#39; => '127.0.0.1',
        'port' => 6379,
);
$handle = new Redis( );
$handle->connect( $config['host'], $config['port'] );
$redis = $handle;
$testKey = 'testKey';
$testVal = 'This is a Test Value';
var_dump($redis->set($testKey, $testVal));
echo '<br>';
var_dump($redis->get($testKey));
Copy after login

Result:

redis installation and php redis extension

The above introduces the redis installation and the redis extension of PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template