Install php redis in the latest version
Install the redis service
The code is as follows: |
Copy code |
Sudo apt-get install redis-server php5-dev build-essential plugin tproc Redis-server: install the redis service Php5-dev: used to dynamically compile the module, if not installed, the following may not find phpize |
After completing the installation of the redis service, you can run the following command to test whether the redis-server is successfully installed:
The code is as follows: |
Copy code |
Redis-cli Set name lyblog // Display OK, indicating that the write is successful Get name // lyblog indicates that data can be read and written normally |
Copy the phpredis package, compile, configure, and install
The code is as follows: |
Copy code |
Git clone git@github.com: nicolasff/phpredis. git Cd phpredis/ Phpize ./Configure Make |
Create and view Debian installation package
The code is as follows: |
Copy code |
/Mkdeb-apache2.sh Dpkg-c phpredis-x86_64.deb Sudo dpkg-I phpredis-x86_64.deb |
Test whether php-redis is successfully installed.
So far, php-redis should have been installed successfully. We can use the following php code for testing:
The code is as follows: |
Copy code |
<? Php $ Redis = new Redis () or die ("www.111cn.net note: Cannot load Redis module ."); $ Redis-> connect ('localhost '); $ Redis-> set ('random ', rand )); Echo $ redis-> get ('random '); ?> |
If an error is reported, it may be that the php-redis module is not enabled. You can use the following command to enable the redis module:
The code is as follows: |
Copy code |
Sudo a2enmod redis |
Install php-redis stable edition
The latest version is usually used by developers for testing. To ensure stable and secure running of the server backup, select a stable version. The following are several commands for installation. The specific functions of these commands are not explained.
The code is as follows: |
Copy code |
Sudo apt-get install redis-server dh-make-php php5-dev build-essential Mkdir redis Cd redis Export DEBFULLNAME = "Maurits van der Schee" Export DEBEMAIL = "m.vanderschee@leaseweb.com" Dh-make-pecl redis Cd php-redis-2.2.3/ Debuild Dpkg-c ../php5-redis_2.2.3-1_amd64.deb Sudo dpkg-I ../php5-redis_2.2.3-1_amd64.deb |
Install php-redis Web management tool phpredisadmin
Similar to mysql databases, Redis also provides Web graphical management tools. First, go to a Web directory and run the following commands to install it:
The code is as follows: |
Copy code |
Git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git Cd phpRedisAdmin/ Cat README. markdown Git submodule init Git submodule update |
You can configure phpredisadmin in config. inc. php.