Table of Contents
Attachment
Home Backend Development PHP7 How to install redis extension in php7

How to install redis extension in php7

Jun 19, 2020 pm 05:14 PM
php php7 redis Expand

How to install redis extension in php7

Start the installation after confirming that it is php7

Move to the download folder: cd /root/src(Choose the specific folder yourself)
Download php7-redis: wget https://github.com/phpredis/phpredis/archive/php7.zip
Rename: mv ./php7.zip ./phpredis-php7. zip
Extract: unzip phpredis-php7.zip
Enter the decompressed directory: cd phpredis-php7
Find where phpize of php7 is: find / -name 'phpize'

//我的出现了3个,第一个是php5.5的,第二个是php7的,第三个是安装php7时解压的文件夹,没删掉,应该用第二个
/usr/bin/phpize
/usr/local/php7/bin/phpize
/root/src/php-7.0.12/scripts/phpize
Copy after login

Recompile phpize: /usr/local/php7/bin/phpize(No need to switch directories, directly execute the one you find phpize)
Find php-config:find / -name 'php-config'

//这个php-config文件同样找到3个,原因跟phpize一样
/usr/bin/php-config
/usr/local/php7/bin/php-config
/root/src/php-7.0.12/scripts/php-config
Copy after login

Write configure:./configure --with-php-config=/ usr/local/php7/bin/php-config (There is no need to switch directories, fill in the found php-config path into the parameters of this command)
Installation: make && make install
Find php.ini: find / -name 'php.ini'

/usr/local/php7/etc/php.ini
/etc/php.ini
Copy after login

Edit php.ini: vi /usr/local/php7/etc/php. ini
Search for extension location: Press the esc key in vi, enter /extension= and press the Enter key to find many extension=, press i to enter the editing mode, find a blank line under the extension=, if there is no blank line, press Enter key to start a new line , write extension=redis.so (this content must be on its own line)

Restart php-fpm: /etc/init.d/php-fpm restart( If the restart fails, please find another way to restart php-fpm. If you are using Apache, just restart Apache)

Okay, now open the phpinfo() page and search for redis to see if you can find it

How to install redis extension in php7

Attachment

If the redis service that php wants to access is not on the local machine, in addition to the correct ip when connecting, the redis service sideredis.conf## The bind line in # should be added to the local IP, and multiple IPs should be separated by spaces, for example: bind 192.168.1.100 10.0.0.1

Recommended tutorial: "php tutorial<a href="https://www.php.cn/course/list/29.html" target="_blank">"</a>

The above is the detailed content of How to install redis extension in php7. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The Future of PHP: Adaptations and Innovations The Future of PHP: Adaptations and Innovations Apr 11, 2025 am 12:01 AM

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

How to build the redis cluster mode How to build the redis cluster mode Apr 10, 2025 pm 10:15 PM

Redis cluster mode deploys Redis instances to multiple servers through sharding, improving scalability and availability. The construction steps are as follows: Create odd Redis instances with different ports; Create 3 sentinel instances, monitor Redis instances and failover; configure sentinel configuration files, add monitoring Redis instance information and failover settings; configure Redis instance configuration files, enable cluster mode and specify the cluster information file path; create nodes.conf file, containing information of each Redis instance; start the cluster, execute the create command to create a cluster and specify the number of replicas; log in to the cluster to execute the CLUSTER INFO command to verify the cluster status; make

How to use the redis command How to use the redis command Apr 10, 2025 pm 08:45 PM

Using the Redis directive requires the following steps: Open the Redis client. Enter the command (verb key value). Provides the required parameters (varies from instruction to instruction). Press Enter to execute the command. Redis returns a response indicating the result of the operation (usually OK or -ERR).

PHP: Is It Dying or Simply Adapting? PHP: Is It Dying or Simply Adapting? Apr 11, 2025 am 12:13 AM

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.

How to clear redis data How to clear redis data Apr 10, 2025 pm 10:06 PM

How to clear Redis data: Use the FLUSHALL command to clear all key values. Use the FLUSHDB command to clear the key value of the currently selected database. Use SELECT to switch databases, and then use FLUSHDB to clear multiple databases. Use the DEL command to delete a specific key. Use the redis-cli tool to clear the data.

How to read redis queue How to read redis queue Apr 10, 2025 pm 10:12 PM

To read a queue from Redis, you need to get the queue name, read the elements using the LPOP command, and process the empty queue. The specific steps are as follows: Get the queue name: name it with the prefix of "queue:" such as "queue:my-queue". Use the LPOP command: Eject the element from the head of the queue and return its value, such as LPOP queue:my-queue. Processing empty queues: If the queue is empty, LPOP returns nil, and you can check whether the queue exists before reading the element.

How to use redis lock How to use redis lock Apr 10, 2025 pm 08:39 PM

Using Redis to lock operations requires obtaining the lock through the SETNX command, and then using the EXPIRE command to set the expiration time. The specific steps are: (1) Use the SETNX command to try to set a key-value pair; (2) Use the EXPIRE command to set the expiration time for the lock; (3) Use the DEL command to delete the lock when the lock is no longer needed.

See all articles