-
- @ubuntu:/$ mkdir /usr/local/redis
- @ubuntu:/$ cd /usr/local/redis
- @ubuntu:/$ wget http://redis.googlecode.com/files/redis -2.4.2.tar.gz
- @ubuntu:/$ tar xzf redis-2.4.2.tar.gz
- @ubuntu:/$ cd redis-2.4.2
- @ubuntu:/$ make
- @ubuntu:/$ src/redis-server
Copy code
redis test command:
@ubuntu:/$ src/redis-cli :/$ redis> get foo @ubuntu:/$ "bar";
- Copy the code
-
-
- 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
-
- dhorrigan
-
- 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
- Copy code
-
-
- 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.
-
- 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.
-
-
|