1.开始之前先打开mysql、nginx、php-ftm
[root@server1 ~]# nginx -s start
[root@server1 ~]# /etc/init.d/php-fpm start
[root@server1 ~]# systemctl start mysqld
2.测试访问
[root@server1 ~]# vim /usr/local/lnmp/nginx/conf/nginx.conf
3.解压软件包
4.建立数据库
5.开始安装配置
添加用户小明
6.登录数据库查看创建的用户是否存在
7.memcache概述
memcache是一套分布式的高速缓存系统,由LiveJournal的Brad Fitzpatrick开发,但目前被许多网站使用以提升网站的访问速度,尤其对于一些大型的、需要频繁访问数据库的网站访问速度提升效果十分显著。这是一套开放源代码软件,以BSD license授权发布。
1、memcache就是一个数据库、但是数据存在内存中。常用来做缓存服务器、将从数据库查询的数据缓存起来,减少数据库查询、加快查询速度。
2、明确使用场景:缓存服务器
3、适合存储的数据:
①访问比较频繁的数据,安全性差的数据,丢失无所谓的数据。
②数据更新,比较频繁的数据,比如用户的在线状态。
③数据的单个键值不能太大,不要超过1Mb数据。
memcached手册:http://www.runoob.com/memcached/memcached-tutorial.html
memcache扩展是完全在PHP框架内开发的,memecached扩展是使用libmemcached的
8.配置插件memcache
9.添加phpize命令
[root@server1 memcache-4.0.5.2]# yum install -y autoconf
10.进行预编译安装
[root@server1 memcache-4.0.5.2]# ./configure --with-php-config=/usr/local/lnmp/php/bin/php-config
完成后php的插件添加完成
11.其实php本身支持一部分插件
[root@server1 openssl]# make && make install 编译安装插件
12.到此为止两个模块已经添加完成接下来去配置文件
13.接下来开始配置memcached服务端
系统本地yum源有memcached软件包,简单点直接使用yum源安装
[root@server1 ~]# yum install -y mem
memcache-4.0.5.2/ memcached.x86_64 memkind.x86_64 memstomp.i686 memstomp.x86_64 memtest86+.x86_64
[root@server1 ~]# yum install -y memcached.x86_64 安装
14.测试memcache能不能加速访问
[root@server1 html]# vim memcache.php
使用压力测试工具来测试访问加速效果(物理机测试)
10次并发五千次请求 用时10s
[root@client ~]# ab -c 10 -n 5000 http://172.25.254.1/index.php
[root@client ~]# ab -c 10 -n 5000 http://172.25.254.1/example.php