search
HomeBackend DevelopmentPHP7Learn about installing redis extension for php7 in centos7

Learn about installing redis extension for php7 in centos7

Feb 24, 2021 am 09:45 AM
centos7php7redis extension

Learn about installing redis extension for php7 in centos7

Recommended (free): PHP7

Download redis

Download redis, unzip and compile:

$ wget http://download.redis.io/releases/redis-4.0.6.tar.gz$ tar xzf redis-4.0.6.tar.gz
$ cd redis-4.0.6$ make && make PREFIX=/usr/local/redis install  #安装到指定目录

Now go to the source directory where the tar package was extracted just now, copy a redis.conf configuration file, and put it in / In the usr/local/redis/bin/ directory

##Enter the redis directory and run vi redis.conf

##Change daemonize no to daemonize yes, save and exit

Start the Redis service through the following command:
##./bin/redis-server ./redis.conf

You can use the built-in client command redis-cli:

$ ./redis-cli
redis> set foo bar
OK
redis> get foo"bar"


The above is to install the redis program

To enable the redis extension in php7

Use git clone to download git phpredis extension package

[root@localhost local ]#git clone  https://github.com/phpredis/phpredis.git
At this step, we need to use phpize generated when installing php to generate the configure configuration file,

//Specific Which one to use depends on the directory where your phpize file is located. In this case, you should use whereis phpize to view the path

[
root@localhost local
 ]
# whereis phpize
phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz

这里表明路径为/usr/bin/phpize,然后执行:

[
root@localhost phpredis
 ]
# /usr/bin/phpize
Can't find PHP headers in /usr/include/php
The php-devel package is required for use of this command.

这里报错了,原因是没有安装好php-devel,由于我是使用的php7.0所以执行以下命令:

[root@localhost phpredis]#yum -y install php70w-devel

然后再次执行:

[root@localhost phpredis]# /usr/bin/phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012

执行完上一步,我们就有了 configure 配置文件了,接下来配置

[root@localhost phpredis]#./configure

或者执行

[root@localhost phpredis]#./configure --with-php-config=/usr/bin/php-config

接下来是编译安装

[root@localhost phpredis]#make 
[root@localhost phpredis]# make install
 Installing shared extensions:      /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/

配置php的配置文件php.ini(具体放在那里可以用 whereis php.ini 来查看),我的配置文件php.ini在/etc/下

[root@localhost phpredis]#vim /etc/php.ini

开启redis扩展:

extension = redis.so

redis.so文件的路径可以在make install的时候看到

[root@localhost local]# php -m  #查询php的扩展


重启nginx服务器,重启php-fpm,使配置生效

重启之后我们打开info.php,已经可以看到redis的扩展信息了


更多相关学习推荐:PHP7教程

The above is the detailed content of Learn about installing redis extension for php7 in centos7. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software