PHP Redis extension from installation to use

*文
Release: 2023-03-18 16:08:02
Original
2976 people have browsed it

Redis is a memory-level nosql database that is widely used because of its high performance. This article mainly introduces the adding of Redis module and connection to PHP with pictures and texts. I hope to be helpful.

The following will introduce how to add Redis extension to php!

The PHP manual does not provide Redis classes and methods, nor does it provide related extension modules. However, we can download PHP extensions from the Redis official website. There are many extensions, only phpredis is the most popular one. example.

1.phpredis download
1. Click "Repository" to enter the Redis learning library, which contains Redis extended code files and related introductions as well as classes and methods

2. Click "releases" to enter the source file of phpredis

3. Download the latest version of phpredis source file, select "tar.gz" to download

2.phpredis configuration
1. Unzip phpredis file

tar -zxvf phpredis-2.2.7.tar.gz
Copy after login


2. Install and configure phpredis
1. Run the phpize5 command in the phpredis directory to generate the configure file

 phpize5
Copy after login


                                                                                                                                        .
4. Modify php.ini and add (in order, add igbinary.so first, then add redis.so)

wget http://pecl.php.net/get/igbinary-1.2.1.tgz
./configure
make
sudo make install
Copy after login


3 View phpredis

1. Use phpinfo() to view

4.php to connect to the redis database
     
1. Open the database service
     2. Create a new redis.php file and type the following code to connect

    

./configure --enable-redis-igbinary
make 
sudo make install
Copy after login

3. Open the file in the browser and view the query results

Related Recommended:

php redis distributed lock and task queue code examples detailed explanation

How to reduce PHP Redis Memory occupancy method sharing (picture and text)

Detailed introduction of PHP redis implementation of super mini full-text retrieval code example

The above is the detailed content of PHP Redis extension from installation to use. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!