Install the redis and phpredis modules

Source: Internet
Author: User
Tags install redis redis server

Download and install redis:@ Ubuntu:/$ mkdir/usr/local/redis @ Ubuntu:/$ CD/usr/local/redis @ Ubuntu:/$ wget unzip tar xzf redis-2.4.2.tar.gz @ Ubuntu: /$ CD redis-2.4.2 @ Ubuntu:/$ make @ Ubuntu:/$ src/redis-Server Redis test command:@ Ubuntu:/$ src/redis-cli @ Ubuntu:/$ redis> set Foo bar @ Ubuntu:/$ OK

@ Ubuntu:/$ redis> Get foo

@ Ubuntu:/$ "bar ";

 

We have installed the redis server program. Now we need to use redis In the project. Because our backend is written in PHP, we need to use it with the redis PHP client. There are several PHP clients:

Predis★ Repository Jol1hahn Mature and supported
Phpredis★ Repository Yowgi This is a client written in C as a PHP module.
Rediska Repository Homepage Shumkov  
Redisent Repository Justinpoliey  
Iredis Repository

Dhorrigan

Here I select phpredis (
C development extension package) This PHP extension.

@ Ubuntu:/$ wget https://download.github.com/owlient-phpredis-2.1.1-1-g90ecd17.tar.gz
@ Ubuntu:/$ tar zxvf owlient-phpredis-2.1.1-1-g90ecd17.tar.gz
@ Ubuntu:/$ CD owlient-phpredis-90ecd17/
@ Ubuntu: // $/usr/local/PHP/bin/phpize
@ Ubuntu:/$./configure -- With-PHP-Config =/usr/local/PHP/bin/PHP-config
@ Ubuntu:/$ make
@ Ubuntu:/$ make install

Note: When developing PHP extensions using C, if you use the dynamic link library to compile the extension module, you need to use phpize. This tool is not installed by default when you use apt-Get install PhP5, install phpize: APT-Get install php5-dev.

 

Modify the configuration file:

Modify the php. ini file

Add the following line to PhP. ini:

Extension = redis. So

It takes effect after nginx is restarted.

 

Enable the redis service: redis-server or redis-server/etc/redis. conf (running in the background ),

If the service is not enabled, "uncaught exception 'redisexception' with message 'redis server went away 'may occur '? "Error

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.