PHP 使用 Redis
PHP 想往 Redis 里增删查改数据,需要先 安装 redis 扩展模块:
cd /usr/local/src/ wget https://coding.net/u/aminglinux/p/yuanke_centos7/git/raw/master/21NOSQL/phpredis.zip unzip phpredis.zip cd phpredis-develop/ /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install echo 'extension = "redis.so"' >> /usr/local/php/etc/php.ini /usr/local/php/bin/php -m | grep redis /etc/init.d/php-fpm restart
把 PHP 的 session(就是用户登录的信息)存到 Redis:
[root@localhost ~]$ vim /usr/local/php/etc/php-fpm.conf [www] // 在进程池中配置 ...... php_value[session.save_handler] = redis php_value[session.save_path] = "tcp://127.0.0.1:6379"
[root@localhost ~]$ /etc/init.d/php-fpm restart