Install redis and phpredis in linux

Source: Internet
Author: User
Tags ini php source code redis install redis redis server

To use redis, you need to install the redis client and operate the redis client interface.

1. Server installation
Apt-get install redis-server
Start Redis

$ Redis-server

Check whether Redis is working?

$ Redis-cli

This will open a Redis prompt, as shown in the following figure:

Redis 127.0.0.1: 6379>

The above prompt 127.0.0.1 is the local IP address, and 6379 is the port running on the Redis server. Enter the PING command, as shown in the following figure.

Redis 127.0.0.1: 6379> ping PONG

This indicates that you have successfully installed Redis on your machine.
Reference: http://www.yiibai.com/redis/redis_quick_guide.html

2. php client

The php operation interface on the client is as follows:
Reference: http://hanqunfeng.iteye.com/blog/1984387
Phpredis download address: https://github.com/phpredis/phpredis

2. 1. Download and decompress

# Wget https://github.com/phpredis/phpredis/archive/develop.zip
# Unzip phpredis-develop.zip

2. Go to the directory to compile and generate the redis. so file.
# Cd phpredis-develop
#/Usr/local/php/bin/phpize
#./Configure-with-php-config =/usr/local/php/bin/php-config
# Make
# Make install

File redis. so Path
Phpredis-develop/modules/redis. so
Phpredis-develop/. libs/redis. so
/Usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/redis. so
The three files are the same file.

. Copy the file redis. so to the extension software directory of php
# Cp modules/redis. so/usr/lib/php5/20100525/
# Cd/usr/lib/php5/20100525/
# Chmod-x redis. so

Note:
/Usr/local/php/bin/phpize is the software of the php5-dev.
Php5-dev is developer version, is used to develop php extension,
She provides some necessary php components for developing and compiling php5 extensions, which are generally header files and dependent libraries of some php source code.
If you need to install some php module through the source code, such as php5-mysql, gd, etc, you need to install php5-dev,
If you need php extensions, you can install them directly through apt-get, without having to install php5-dev.
After installation, you can view the files in this package through the dpkg-query-L php5-dev

2. 4. Configure php. ini to load redis. so

In the default lnmp environment, the file structure is that available configuration files are stored separately, and the link files of enabled configuration files are stored in the enable configuration directory conf. d.
Create the redis configuration file redis. ini
# Vim/etc/php5/mod-available/redis. ini
Join
Extension = redis. so

Link redis. ini to the enable configuration Directory for the configuration to take effect.
# Cd/etc/php5/conf. d
# Ln-s ../mod-available/redis. ini 20-redis.ini

Restart Apache. If The nginx is connected, restart php-fpm.

-----------------------------------
Installation method in windows

Download the compiled dll file from the internet. You must select the version corresponding to php.
After the download, put php_igbinary.dll and php_redis.dll in the php ext directory,

Modify php. ini and add the two extensions. Do not reverse the order.

Extension = php_igbinary.dll
Extension = php_redis.dll

Download file:

Php_redis-5.5-vc11-ts-x86-00233a.zip http://d-h.st/4A5
Php_igbinary-5.5-vc11-ts-x86-c35d48.zip http://d-h.st/QGH

Php_redis-5.5-vc11-nts-x86-00233a.zip http://d-h.st/uGS
Php_igbinary-5.5-vc11-nts-x86-c35d48.zip http://d-h.st/bei

Php_redis-5.5-vc11-ts-x64-00233a.zip http://d-h.st/1tO
Php_igbinary-5.5-vc11-ts-x64-c35d48.zip http://d-h.st/rYb

Php_redis-5.5-vc11-nts-x64-00233a.zip http://d-h.st/N0d
Php_igbinary-5.5-vc11-nts-x64-c35d48.zip http://d-h.st/c1a

Restart Apache.

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.