tar zxf memcache-2.2.7.tgz cd memcache-2.2.7 phpize //生成configure文件,如果报错找不到该命令是因为没有对php程序做路径优化 ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config make && make install
修改php配置文件
1 2 3
vi /usr/local/php/php.ini 添加: extension=memcache.so
重启服务
1
service php-fpm restart
验证php是否成功连接memcache
1 2 3 4
vi /usr/local/nginx/html/index.php <?php phpinfo(); ?>
访问172.16.1.12/index.php
数据库授权
1 2 3 4 5 6 7 8 9 10 11
登录数据库 mysql -uroot -p123.com 创建测试使用的数据库和表 create database abc; use abc; create table test (id int,name char(10)); 表中添加数据 Insert into test values (1,”one”),(2,”two”),(3,”three”),(4,”four”),(5,”five”); 数据库授权,允许php连接 grant all on *.* to ‘root’@’172.16.1.%’ identified by ‘123.com’; flush privileges;