Q:-How to memcache in linux(Red Head) plateform?
Ans:-
1- put libevent-1.4.9-stable(OR higher Version) and memcached-1.3.0(OR higher Version) in /usr/src folder and memcache-2.2.7(Or higher version) in /usr/local/src.
2-then in linux prompt go to
cd /usr/src
cd libevent-1.4.9-stable/
./configure
make
make install
Then open file in Vi Editor using following command:-
vi /root/.bash_profile
then append (in not exist) LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH
Then after save it using :wq.
3:- sudo ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib
4:- cd memcached-1.3.0/
5:- ./configure
6:- make
7:- make install
8:- memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 .u nobody
OR
memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211(OR USING BOTH),
9:- cd /usr/local/src
10:- cd memcache-2.2.7/(all ready available this rpm in particular directory ).Then
phpize
./configure
make && make install
Then Open following file in vi editor
vi /etc/php.ini
append extension=memcache.so
Then use given below command
cp modules/memcache.so /usr/lib64/php/modules/
command in linux
touch /etc/php.d/memcached.ini
echo 'extension=memcache.so' > /etc/php.d/memcached.ini
Ans:-
1- put libevent-1.4.9-stable(OR higher Version) and memcached-1.3.0(OR higher Version) in /usr/src folder and memcache-2.2.7(Or higher version) in /usr/local/src.
2-then in linux prompt go to
cd /usr/src
cd libevent-1.4.9-stable/
./configure
make
make install
Then open file in Vi Editor using following command:-
vi /root/.bash_profile
then append (in not exist) LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH
Then after save it using :wq.
3:- sudo ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib
4:- cd memcached-1.3.0/
5:- ./configure
6:- make
7:- make install
8:- memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 .u nobody
OR
memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211(OR USING BOTH),
9:- cd /usr/local/src
10:- cd memcache-2.2.7/(all ready available this rpm in particular directory ).Then
phpize
./configure
make && make install
Then Open following file in vi editor
vi /etc/php.ini
append extension=memcache.so
Then use given below command
cp modules/memcache.so /usr/lib64/php/modules/
command in linux
touch /etc/php.d/memcached.ini
echo 'extension=memcache.so' > /etc/php.d/memcached.ini
then in vi editor
vi /etc/ld.so.conf
include include ld.so.conf.d/*.conf
service httpd restart(Restart apache).
I hope above Doc will help u.
Thanks
memcache post:--
ReplyDeleteconnect("localhost",11211); // try 127.0.0.1 instead of localhost
// if it is not working
echo "Server's version: " . $memcache->getVersion() . "
\n";
// we will create an array which will be stored in cache serialized
$testArray = array('horse', 'cow', 'pig');
$tmp = serialize($testArray);
$memcache->add("key", $tmp, 30);
echo "Data from the cache:
\n";
print_r(unserialize($memcache->get("key")));
*/
?>
connect('localhost', 11211);
/*
set value of item with key 'var_key', using on-the-fly compression
expire time is 50 seconds
*/
if($memcache_obj->get('var_key')){
echo $memcache_obj->get('var_key');
echo "---------------Cached";
}else{
$memcache_obj->set('var_key', 'some really big variable', MEMCACHE_COMPRESSED, 1250);
echo "--------Not-------Cached";
}
if($memcache_obj->get('var_keyTest1page')){
echo $memcache_obj->get('var_keyTest1page');
echo "---------------Cached";
}else{
$memcache_obj->set('var_keyTest1page', 'some really big sdsd sdsad sdasd ssds ssfs sffdf fsdf variable', MEMCACHE_COMPRESSED, 1250);
echo "--------Not-------Cached";
}
?>