Home  >  Article  >  Backend Development  >  How to install extended redis in php under linux

How to install extended redis in php under linux

藏色散人
藏色散人Original
2020-07-14 09:47:122379browse

How to install extensions in PHP under Linux: first install the compilation tool; then download the "phpredis" extension and complete the installation; then add "extension="redis.so""; finally open "index.php" in the browser That’s it.

How to install extended redis in php under linux

Instructions:

操作系统:CentOS
php安装目录:/usr/local/php
php.ini配置文件路径:/usr/local/php/etc/php.ini
Nginx安装目录:/usr/local/nginx
Nginx网站根目录:/usr/local/nginx/html

1. Install the compilation tool

yum install wget  make gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel kernel keyutils  patch perl

2. Install redis

Download :https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz

Upload phpredis-2.2.4.tar.gz to the /usr/local/src directory

cd /usr/local/src #进入软件包存放目录
tar zxvf phpredis-2.2.4.tar.gz #解压
cd phpredis-2.2.4 #进入安装目录
/usr/local/php/bin/phpize #用phpize生成configure配置文件
./configure --with-php-config=/usr/local/php/bin/php-config  #配置
make  #编译
make install  #安装

After the installation is completed, the following installation path appears

/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/

3. Configure php support

vi /usr/local/php/etc/php.ini #Edit the configuration file at the end Add the following content in one line

Add

extension="redis.so"
:wq! #保存退出

4. Test

vi /usr/local/nginx/html/index.php   #编辑
<?php
phpinfo();
?>
:wq! #保存退出

Open index.php in the browser, as shown in the figure below, you can see redis related information

How to install extended redis in php under linux

At this point, the PHP redis installation under Linux is completed!

For more related knowledge, please visit PHP Chinese website!

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

Statement:
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