Home>Article>Backend Development> How to install redis extension for php7 in centos7
This article will introduce to you how to install the redis extension for php7 in centos7. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Download redis
Download redis, unzip, 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 tar package and unzip it In the source code directory, copy a redis.conf configuration file and place it in the /usr/local/redis/bin/ directory.
Enter the redis directory and run vi redis.conf
to 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 the phpredis expansion package on git
[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 use Which one 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
This indicates that the path is /usr/bin/phpize, and then execute:
[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.
An error is reported here. The reason is that php-devel is not installed. Since I am using php7.0, I execute the following command:
[root@localhost phpredis]#yum -y install php70w-devel
and then execute it again:
[root@localhost phpredis]# /usr/bin/phpize Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012
After executing the previous step, we There is a configure configuration file. Next, configure
[root@localhost phpredis]#./configure
or execute
[root@localhost phpredis]#./configure --with-php-config=/usr/bin/php-config
. Next is to compile and install
[root@localhost phpredis]#make [root@localhost phpredis]# make install Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/
to configure the php configuration file php.ini (specifically put There you can use whereis php.ini to view), my configuration file php.ini is under /etc/
[root@localhost phpredis]#vim /etc/php.ini
Enable redis extension:
extension = redis.so
The path of the redis.so file can be found in When making install, I see
[root@localhost local]# php -m #Query the extension of php
Restart the nginx server and restart php-fpm, make the configuration take effect
After restarting, we open info.php and you can already see the extended information of redis
Recommended learning:php video tutorial
The above is the detailed content of How to install redis extension for php7 in centos7. For more information, please follow other related articles on the PHP Chinese website!