An example of installing the redis and phpredis modules
- @ 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
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 supportedphpredis★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 the PHP extension phpredis (C-developed extension package.
- @ 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 and add the following line to php. ini: extension = redis. so. restart nginx and the line will take effect. 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. |