Install and configure php redis extension in Ubuntu

Source: Internet
Author: User
Tags install php php code php redis redis git clone install redis

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.