An example of installing redis and phpredis modules

WBOY
Release: 2016-07-25 09:07:18
Original
1136 people have browsed it
  1. @ubuntu:/$ mkdir /usr/local/redis
  2. @ubuntu:/$ cd /usr/local/redis
  3. @ubuntu:/$ wget http://redis.googlecode.com/files/redis -2.4.2.tar.gz
  4. @ubuntu:/$ tar xzf redis-2.4.2.tar.gz
  5. @ubuntu:/$ cd redis-2.4.2
  6. @ubuntu:/$ make
  7. @ubuntu:/$ src/redis-server
Copy code

redis test command: @ubuntu:/$ src/redis-cli :/$ redis> get foo

@ubuntu:/$ "bar";

  1. Copy the code
  2. The server-side program of redis is installed. Now we need to use REDIS in the project. Since we The backend is written in PHP, so you need to use the redis PHP client to use it. 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
  3. dhorrigan
  4. Here I choose the PHP extension phpredis (expansion package developed in C).

@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
  1. Copy code
  2. Note: When developing PHP extensions in C If you use a dynamic link library to compile extension modules, you need to use phpize. This tool is not installed by default when using apt-get install php5. To install phpize: apt-get install php5-dev.
  3. Modify configuration file: Modify the php.ini file Add the following line to php.ini: extension=redis.so It will take effect after restarting nginx. Finally, enable the redis service: redis-server or redis-server /etc/redis.conf (running in the background). If the service is not enabled, an "Uncaught exception 'RedisException' with message 'Redis server went away'?" error may occur.

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