php + memcache cache

Original Address: https://blog.csdn.net/qq_33571752/article/details/86494667

# Modified on the basis of lnmp

Dependence libevent library

cd lnmp/
tar zxf memcache-2.2.5.tgz
cd memcache-2.2.5

Environment # Configure php
~ / .bash_profile vim
added: / usr / local / lnmp / php / bin


source ~/.bash_profile

 

# Execute the following command, and then compile
phpize

/configure


make && make install

 

# Modify the configuration of the php configuration of
vim /usr/local/lnmp/php/etc/php.ini

# Reload phph

/etc/init.d/php-fpm reload
php -m | grep memachecat
cat /etc/sysconfig/memcached

# Download memcached service

the install the memcached -Y yum
# start connecting the memcached
/etc/init.d/memcached Start

 

# 安装ipenresty,基于nginx和lua
tar zxf openresty-1.13.6.1.tar.gz
cd openresty-1.13.6.1
./configure
gmake && gmake install

 

#复制文件
cd /root/lnmp/memcache-2.2.5
cp memcache.php  example.php  /usr/local/openresty/nginx/html/

#修改如下

vim memcache.php
define('ADMIN_USERNAME','memcache');    // Admin Username
define('ADMIN_PASSWORD','redhat');      // Admin Password
$MEMCACHE_SERVERS[] = '172.25.42.1:11211'; // add more as an array
#$MEMCACHE_SERVERS[] = 'mymemcache-server2:11211'; // add more as an array

 

# 然后配置openresty下的nginx

vim /usr/local/openresty/nginx/conf/nginx.conf

 

启动openresty下的nginx

#浏览器登陆mencache统计页面,输入我们刚刚配置的用户和密码登陆

通过命令测试,两次访问时间相差几倍

ab -c 1 -n 1 http://172.25.70.1/example.php

Guess you like

Origin www.cnblogs.com/phpk/p/10938080.html