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.
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 #编辑 :wq! #保存退出
Open index.php in the browser, as shown in the figure below, you can see redis related information
At this point, the PHP redis installation under Linux is completed!
For more related knowledge, please visitPHP 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!