利用APCu作为本地缓存,同时使用Memcahed将缓存分布到多台服务器上,提高性能。
yum install -y php-pecl-apcuDebian/Ubuntu/Mint:systemctl restart httpd
apt-get install php5-apcu/trusty-backports systemctl restart httpd
yum -y install gcc gcc-c++从官网中下载最新的 memcached http://www.memcached.org/
tar -xvf memcached-1.4.15.tar.gz出现了 configure: error: libevent is required. You can get it from http://www.monkey.org/~provos/libevent/cd memcached-1.4.15
./configure –prefix=/usr/local/memcache
就直接去,那个网站下载
tar zxvf libevent-1.2.tar.gz cd libevent-1.2 ./configure -prefix=/usr make make install
编译安装php模块的memcache模块 下载地址 http://pecl.php.net/package/memcache tar -xvf memcache-2.2.7.tar.gz cd memcache-2.2.7 #/usr/local/php/bin/phpize #./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache make & make install #/usr/local/bin/memcached -d -m 10 -u root -l 192.168.12.201 -p 13001 -c 256 -P /tmp/memcached.pid #启动memcache
yum install memcached php-pecl-memcachedDebian/Ubuntu/Mint:systemctl start memcached
apt-get install memcached php5-memcached systemctl start memcached
重启apache:
systemctl restart httpd #centos/hat/fedora systemctl restart apache2 #ubuntu/debain/mint
您可以验证Memcached守护程序是否正在使用ps ax运行:
ps ax | grep memcached 19563 ? Sl 0:02 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1
vim /var/www/html/nextcloud/config/config.php在
);
前添加下面的的代码:
'memcache.local' => '\OC\Memcache\APCu', 'memcache.distributed' => '\OC\Memcache\Memcached', 'memcached_servers' => array( array('localhost', 11211), array('server1.example.com', 11211), array('server2.example.com', 11211), ),其中
array('server1.example.com', 11211), array('server2.example.com', 11211),指向第二、第三台memcached服务器(如果没有,这两行必须删去。同理,按以上格式可以增加更多memcached服务器),实现将数据缓存分布到多个服务器上。
如图:
APCu+Memcahed已开启