Install, configure and use phpRedis
Install Redis before installing phpRedis.
1. Download and install
On a Linux server, run the following command on the command line (the General source code of cd./usr local/src is put here (the installation of source code is recommended ))
wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gztar zxvf phpredis-2.2.4.tar.gzcd phpredis-2.2.4/usr/local/php5.5.30/bin/phpize
./configure --with-php-config=/usr/local/php5.5.30/bin/php-config
make make install
Note:
Wget: Download the remote file to the local folder.
Tar xzf: Decompress the file to the current folder directory.
Cd: Enter the folder
/Usr/local/php/php5.5.30/phpize use phpize to generate the configure configuration file
./Configure -- with-php-config =/usr/local/php5.5.30/bin/php-config configure php so that it can use redis
Make install: install redis
Error message:
If the configure configuration file is generated using phpize, the following error occurs: Cannot find autoconf. When php is configured, the following error occurs:./configure does not have the file or directory.
Solution:
Run the following command:
wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gztar -zvxf m4-1.4.9.tar.gzcd m4-1.4.9/./configure && make && make installcd ../wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gztar -zvxf autoconf-2.62.tar.gzcd autoconf-2.62/./configure && make && make install
After the installation is successful, you can see the following folder (remember this folder name may be different, but the format is the same no-debug-zts-20121212)
/Usr/local/php5.5.30/lib/php/extensions/no-debug-zts-20121212/
2. Configure phpRedis
Open the php configuration file/usr/local/php/etc/php. ini to add code (reminder to see how much your no-debug-zts-20121212 is, don't copy it ):
extension_dir = "/usr/local/php5.5.30/lib/php/extensions/no-debug-zts-20121212"extension=redis.so
Restart apache:
/usr/local/apache/bin/apachectl restart
Now, executing phpinfo () indicates that phpRedis is successfully installed.
3. Simple test using the phpRedis plug-in to operate Redis
<?php $redis = new redis();$redis->connect('127.0.0.1', 6379);$redis->set('foo','bar');echo $redis->get('foo');
The output result is bar.
It indicates the success ~
You may also like the following articles about Redis. For details, refer:
Install and test Redis in Ubuntu 14.04
Basic configuration of Redis master-slave Replication
Redis cluster details
Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis
Redis series-installation, deployment, and maintenance
Install Redis in CentOS 6.3
Learning notes on Redis installation and deployment
Redis. conf
Redis details: click here
Redis: click here
This article permanently updates the link address: