Home > Article > Backend Development > PHP Redis extension from installation to use
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
2. Install and configure phpredis
1. Run the phpize5 command in the phpredis directory to generate the configure file
phpize5
.
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
3 View phpredis
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
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!