Redis is the remote dictionary service. It is an open source log-type Key-Value database written in ANSI C language, supports the network, can be memory-based and persistent, and provides APIs in multiple languages.
1. Download the source code, decompress it and compile the source code.
wget http://download.redis.io/releases/redis-4.0.2.tar.gz tar xzf redis-4.0.2.tar.gz cd xzf redis-4.0.2 make
2. After compilation is completed, there are four executable files redis-server, redis-benchmark, redis-cli and redis.conf in the Src directory. Then copy it to a directory. (redis.conf may also be in the upper layer)
mkdir /usr/redis cp redis-server /usr/redis cp redis-benchmark /usr/redis cp redis-cli /usr/redis cp redis.conf /usr/redis cd /usr/redis
3. Start the Redis service.
./redis-server // ./redis-server & 后台运行
4. Then use the client to test whether the startup is successful.
$ redis-cli redis> set foo bar OK redis> get foo "bar"
Install redis extension
Download: https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz
Supplement:
phpredis extension download address:
<a href="https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxcheckurl?requrl=https%3A%2F%2Fgithub.com%2Fphpredis%2Fphpredis%2Farchive%2Fdevelop.zip&skey=%40crypt_4f202e30_6b2e50deafd322d9820dc0babc08935e&deviceid=e090189265878664&pass_ticket=3HpM538HybnH5DP2QwHWMhZNdF0vPv6uHPr2IznqqzvtpYh0CuYPCEhOCuivsCLT&opcode=2&scene=1&username=@351cedf05d7cbf94d9732b481f0dba13ed94dc5a13b422c905cca85ae2a54ec3" rel="nofollow" style="background:transparent;color:rgb(202,12,22);">https://github.com/phpredis/phpredis/archive/develop.zip</a>
If the above one does not work, use the following address (the test environment of the following address is: php7.1 redis 4.0.2)
Other steps are the same
Upload phpredis-2.2.4.tar.gz to the /usr/local/src directory
cd /usr/local/src #进入软件包存放目录 tar zxvf phpredis-2.2.4.tar.gz #解压 cd phpredis-2.2.4 #进入安装目录 /usr/local/php/bin/phpize #用phpize生成configure配置文件 ./configure --with-php-config=/usr/local/php/bin/php-config #配置 make #编译 make install #安装
After the installation is completed, the following installation path appears
/usr/local/ php/lib/php/extensions/no-debug-non-zts-20090626/
2. Configure php support
vi /usr/local/php/etc/php.ini #Edit Configuration file, add the following content in the last line
Add
extension="redis.so"
:wq! #Save and exit
3. Restart Service
service php-fpm restart
For more redis knowledge, please pay attention to the PHP Chinese websiteredis tutorial column.
The above is the detailed content of Installation of redis and redis extensions on Linux platform. For more information, please follow other related articles on the PHP Chinese website!