First, install the PHP extension redis
1. Download: http: //pecl.php.net/package/redis Download redis-4.2.0.tgz
Sftp upload tool that can be uploaded through to the installation directory of the server I usually put / usr / local directory
2, installation
tar
-zxvf redis-4.2.0.tgz
cd
redis-4.2.0
/usr/local/php/bin/phpize
.
/configure
--with-php-config=
/usr/local/php/bin/php-config
make
Executing the executable make make test look at whether the error, and then be resolved by an error
make
install
Note: The directory is compiled in the red box of redis.so file is located, php extensions generally placed / usr / lib64 / php / modules , need to redis.so copy on php extension directory
3, Configuration
Note: the php.ini file in /etc/php.ini,/usr/local/php/etc/php
.ini 两个位置,
If the ini file the wrong place, you can run php --ini
to find the ini file path actually loaded, the choice need to modify the php.ini file
Edit the php.ini configuration file, add the following configuration, extension_dir is that the fifth step of storing the extended path (extension_dir choose not to configure, read extended if the default directory)
Enter "/etc/php.d/" folder, create a redis.ini file, as follows
Save and exit, in execution
Restart nginx, look at phpinfo, has expanded redis
View php extensions: php -m
You might encounter an error:
1、重启php-fpm ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)
The reason for the 9000 port is occupied
Remedy: killall php-fpm and then execute php-fpm
2、linux下安装PHP redis扩展,php -m 查看提示undefined symbol: php_session_validate_sid in Unknown on line 0
解决措施:ln -s /usr/local/php/bin/php /usr/bin/php
如果提示/usr/bin/php是存在的,那就删掉php文件,再执行上面那个命令就好
3、还可能遇到某个函数被禁用,这时候查看php.ini文件 搜索disable_functions,将禁用函数移除即可!