วิธีติดตั้ง PHP-MemCache Module On CentOS

แชร์ความรู้ Linux Ubuntu Web Server บทความ การ config server Linux FreeBSD Apache
การติดตั้ง XAMPP Mysql PHP ใครต้องการแชร์ความรู้เรื่องต่างๆ เหล่านี้ให้ ท่านหรืออื่น โพสที่หมวดนี้ได้

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

วิธีติดตั้ง PHP-MemCache Module On CentOS

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

วิธีติดตั้ง PHP-MemCache Module On CentOS
และ MemCache extension ของ php
เพื่อทำให้ Server เราใช้งาน MemCache ได้


“MemCached” is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

In this howto I explain how you can very easily install it and make it avaible in PHP.

You need to activate the RPMForge custom repository (formely known as Dag Wieers): http://dag.wieers.com/rpm/packages/rpmforge-release/

Grab your specific RPM and install it:

โค้ด: เลือกทั้งหมด

wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-*.rpm
rpm --install rpmforge-release-*.rpm

yum install --enablerepo=rpmforge memcached
Now memcached is installed.

You can test it:

โค้ด: เลือกทั้งหมด

memcached -m 512 -u nobody -vv
First, you start up the memcached daemon on as many spare machines as you have. The daemon has no configuration file, just a few command line options, only 3 or 4 of which you'll likely use:

โค้ด: เลือกทั้งหมด

./memcached -d -m 2048 -l 10.0.0.40 -p 11211 -u nobody
This starts memcached up as a daemon, using 2GB of memory, and listening on IP 10.0.0.40, port 11211. The -m switch specifies the amount of memory in megabytes. The -l switch specifies the IP to listen on and finally the -p switch specifies the port to listen on. The default port is 11211 and if your machine has just 1 IP you can omit the -l parameter. In the above example I set the amount of memory to 2GB. Of course you should use a sensible amount of memory. Making your machine swap to disk sort of defeats the purpose of a memory cache daemon. Note that it's perfectly fine to run the memcached daemon on another machine than the one you're running your actual PHP project on. You could even set up a machine totally dedicated to being a memory cache server. And if that's not even enough you can set up multiple servers as well. The sky is the limit. Note: if you try to start the memcached as root it will require you to specify a user under which it should run with an additional -u nobody.

Installation of the PHP MemCache extension:

โค้ด: เลือกทั้งหมด

cd /files/download/

wget http://pecl.php.net/get/memcache-2.1.2.tgz

tar -xvf memcache-2.1.2.tgz

cd memcache-2.1.2

phpize && ./configure --enable-memcache && make
Copy the file memcache.so to the default module directory.

โค้ด: เลือกทั้งหมด

vi /etc/php.ini
Add

โค้ด: เลือกทั้งหมด

extension=memcache.so

โค้ด: เลือกทั้งหมด

/etc/init.d/httpd restart
If you check your phpinfo() you should see a MemCache section appear.

You can now fully use the MemCache functionality in your PHP.


References

http://www.danga.com/memcached/
http://dk.php.net/manual/en/ref.memcache.php

ที่มา: howtoforge.com
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 67