PHP + memcacheのキャッシュ

オリジナル住所:https://blog.csdn.net/qq_33571752/article/details/86494667

#LNMPに基づいて変更されました

依存libeventライブラリー

CDのLNMP /
タールzxfのmemcache-2.2.5.tgzの
CDのmemcacheの-2.2.5

環境#の設定のPHP
〜/ .bash_profileのvimの
追加:は/ usr / local / LNMP / PHP / binに


ソース〜/ .bash_profileの

 

#以下のコマンドを実行して、コンパイル
は、phpizeを

/設定


作る&& make installを

 

#のPHPの設定の構成を変更する
vimの/usr/local/lnmp/php/etc/php.iniを

#リロードphph

/etc/init.d/php-fpmリロード
PHPの-m | グレップのmemachecatの
猫の/ etc /のsysconfig / memcachedの

#ダウンロードmemcachedのサービス

memcachedのインストール-Y yumの
#はmemcachedの接続開始
/etc/init.d/memcachedスタート

 

# 安装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

おすすめ

転載: www.cnblogs.com/phpk/p/10938080.html