|NO.Z.00108|——————————|^^ 部署 ^^|——|Linux&MySQL+Redis.V02|——|Redis+MySQL|

一、安装 redis
### --- 部署Redis服务

[root@server21 ~]# cd redis-mysql
[root@server21 redis-mysql]# tar -zxvf redis-2.8.19.tar.gz
[root@server21 redis-mysql]# cd redis-2.8.19
[root@server21 redis-2.8.19]# make
[root@server21 redis-2.8.19]# make PREFIX=/usr/local/redis install
cd src && make install
make[1]: Entering directory `/root/redis-mysql/redis-2.8.19/src'

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/root/redis-mysql/redis-2.8.19/src'
### --- 拷贝redis服务文件

[root@server21 redis-2.8.19]# cp -a redis.conf /usr/local/redis/
二、安装提供 php 和 redis 联系的软件
### --- 解压

[root@server21 redis-2.8.19]# cd .. 
[root@server21 redis-mysql]# unzip phpredis-master.zip 
[root@server21 redis-mysql]# cd phpredis-master
### --- 安装

[root@server21 phpredis-master]# phpize                         // 其实就是安装一个模块
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
[root@server21 phpredis-master]# ./configure --with-php-config=/usr/bin/php-config
[root@server21 phpredis-master]# make && make install
Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/lib64/php/modules/
 
### --- 让 php 支持 redis
~~~     刷新http://20.20.20.21/输出Redis配置,说明配置OK

[root@server21 phpredis-master]# vim /etc/php.ini
extension=redis.so                                               // 在末尾添加如下内容           #在PHP主配置文件中添加Redis
[root@server21 phpredis-master]# service php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm:                                          [  OK  ]
三、进入 mysql 写入数据
### --- 进入 mysql 写入数据

[root@server21 ~]# mysql -uroot -p123456
### --- 创建一个mytest库

mysql> create database mytest;
Query OK, 1 row affected (0.00 sec)

mysql> use mytest;
Database changed
mysql> create table test (id int,name char(20));
Query OK, 0 rows affected (0.07 sec)
mysql> insert into test values (1,'a1'),(2,'a2'),(3,'a3'),(4,'a4'),(5,'a5');
Query OK, 5 rows affected (0.00 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql> select * from test;
+------+------+
| id   | name |
+------+------+
|    1 | a1   |
|    2 | a2   |
|    3 | a3   |
|    4 | a4   |
|    5 | a5   |
+------+------+
5 rows in set (0.00 sec)

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on 2022-03-26 22:54  yanqi_vip  阅读(6)  评论(0)    收藏  举报

导航