产品服务AMH 免费服务器主机面板SSL证书 免费SSL证书申请编程助手免费智能写代码、翻译NewAMYSQL 免费MySQL管理工具AMFTP 免费FTP管理客户端

AMH 社区首页

 AMH社区 - 开放自由有价值的社区

[求助帖] 用YUM的方法安装 Memcache数据库缓存

chenghua
铝牌会员
377.00 价值分

chenghua 发表于 2013-07-07 11:56:56
本来使用“爱洞特漏”的方法安装Memcache,结果安装结束后memcached一直启动不了。

后来使用yum的方法才搞定,特此把安装过程贴出来,来帮助和我遇到一样问题的朋友:

第一步安装 memcache php 扩展
----------------------------------------------------------------------------------------------
1、依次运行如下命令:
#wget http://pecl.php.net/get/memcache-2.2.6.tgz;
#tar zxvf memcache-2.2.6.tgz;
#cd memcache-2.2.6;
#/usr/local/php/bin/phpize;
#./configure --with-php-config=/usr/local/php/bin/php-config;
#make;
#make install;


2、显示如下信息时为安装成功:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/


3、修改php配置文件,载入memcache
#vi /etc/php.ini
在最后加上下面的代码
[memcache]
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
extension = "memcache.so"


4、刷新PHP配置
#killall php-fpm
#/usr/local/php/sbin/php-fpm
查看phpinfo中是否有memcache一项,有则成功
(如果安装完网站提示出现502 只需要进面板 HOST界面 点击php运行即可)
----------------------------------------------------------------------------------------------






第二步安装 memcached
----------------------------------------------------------------------------------------------

1、安装memcached
#yum -y install memcached


2、启动进程
#memcached -d -u root -m 128 -l 127.0.0.1 -p 12121 -c 256 -P /tmp/memcached.pid
(说明:创建一个128MB,只允许本机 127.0.0.1 连接,端口号是 12121,并发数是 256)


3、添加开机启动进程,
#vi /etc/rc.d/rc.local
加入
memcached -d -u root -m 128 -l 127.0.0.1 -p 12121 -c 256 -P /tmp/memcached.pid



备注:如果要结束Memcache进程:
#pkill memcached
----------------------------------------------------------------------------------------------
OK,到这里结束了。





最后再问一个小问题:我使用eAccelerator来加速PHP。并且想用它来缓存数据库,但是使用eaccelerator_put却提示:“Fatal error: Call to undefined function eaccelerator_put()”。请问是什么问题?
评价: 这个问题有价值吗?  没有 (0分)   有, 感谢 (1分)
2013-07-07 11:56:56 1

amysql
创始人
99530.04 价值分

Call to undefined function eaccelerator_put()

应该不支持吧,
只看到有
引用:
[1219] => eaccelerator_caching
[1220] => eaccelerator_clear
[1221] => eaccelerator_clean
[1222] => eaccelerator_info
[1223] => eaccelerator_purge
[1224] => eaccelerator_cached_scripts
[1225] => eaccelerator_removed_scripts
[1226] => eaccelerator_check_mtime
[1227] => eaccelerator_optimizer

这些函数,
要用自定义缓存,还是用别的缓存扩展。
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-07-07 15:36:59 2

AMH面板 - 好用高效低占用、安全可靠极稳定

chenghua
铝牌会员
377.00 价值分

引用:
amysql 发表于 2013-7-7 15:36
Call to undefined function eaccelerator_put()

应该不支持吧,


感觉好像只有旧版本的支持eaccelerator_put、eaccelerator_get等操作?

比如0.9.5.3
https://code.google.com/p/autosetup1/downloads/detail?name=eaccelerator-0.9.5.3.tar.bz2&can=2&q=

下载这个解压缩

doc\php\shared_memory.php

这个文件就介绍了,如何使用eaccelerator_put、eaccelerator_get

<?php
/*
* This file is a file with dummy php function to document the functions in
* the eAccelerator extension.
*/

/**
* eAccelerator shared memory access.
* eAccelerator can be used to store data in shared memory and share this
* between script. This can be used instead of the php shm or shmop API.
* These functions can be enabled with --with-eaccelerator-shared-memory
* at compile time
*
* @package eAccelerator
*/

/**
* Put key.
* Put key in the eaccelerator shared memory.
* eAccelerator doesn't serialize object, so you need to do it you're self or
* php will segfault on object retrieval.
*
* @param string The key to identify the data
* @param mixed The data to store in shared memory
* @param int Cache the key for $ttl seconds, 0 for never
* @return boolean Returns true if the function was succesfull otherwise it
* will return false. When false is returned, this could mean the limit of
* the total cache is exceeded or the size of the data is to big for the
* eaccelerator.shm_max directive.
* @see eaccelerator_get()
* @see eaccelerator_rm()
*/
function eaccelerator_put ($key, $value, $ttl = 0) {}

/**
* Get data.
* Get data from shared memory. Object need to be serialized when storing them
* so unserializing is necessary when retrieving them.
*
* @param string The key to identify the data
* @return mixed Returns the requested data on succes otherwise NULL if the key doesn't exist or the key was expired.
* @see eaccelerator_put()
*/
function eaccelerator_get ($key) {}

/**
* Remove key.
* Remove key from shared memory
*
* @param string The key to identify the data
* @return boolean Return true on success and false on failure
* @see eaccelerator_put()
*/
function eaccelerator_rm ($key) {}

/**
* Garbage collection.
* Removes expired keys (session data and content) from shared memory
*/
function eaccelerator_gc () {}

/**
* Lock.
* Create a lock with the given key, this allows you to prevent concurrent
* access to some part of your code. Warning, you don't need this to lock the
* keys used with eaccelerator_get and eaccelerator_put. The lock can be
* released with eaccelerator_unlock or automatic at the end of the request.
*
* @param string The key to identify the data to lock
* @return boolean Return true on success and false on failure
* @see eaccelerator_unlock()
* @example eaccelerator_lock.php Lock example
*/
function eaccelerator_lock ($key) {}

/**
* Unlock.
* Unlock the access to a key
*
* @param string The key to identify the data to lock
* @return boolean Return true on success and false on failure
* @see eaccelerator_lock()
*/
function eaccelerator_unlock ($key) {}

?>

评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-07-07 16:01:02 3

amysql
创始人
99530.04 价值分

引用:
chenghua 发表于 2013-7-7 16:01
感觉好像只有旧版本的支持eaccelerator_put、eaccelerator_get等操作?

比如0.9.5.3


eaccelerator-0.9.6.1
doc/php下面只有info
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-07-07 16:14:39 4

chenghua
铝牌会员
377.00 价值分

引用:
amysql 发表于 2013-7-7 16:14
eaccelerator-0.9.6.1
doc/php下面只有info


那应该是新版本没有这些功能。。。无奈了。。:L
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-07-07 16:32:57 5

chenghua
铝牌会员
377.00 价值分

http://www.discuz.net/thread-1913867-1-1.html

0.9.6开始 这个软件去掉了缓存函数

:L
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-07-07 17:43:28 6
 1  (总1页)
AMH社区列表
用户服务中心