1.登入 whm 後,使用easyapache 開啟memcache。
這時透過 php info 還無法看到memcache被啟動。
2.在 centos shell 底下,執行一行安裝語法:
yum -y install memcached.x86_64 php-pecl-memcache.x86_64
3.回到 whm 裡,software > Module Installers > php pecl > manage
搜索: memcache ,在點下 go ,搜索完成後,在點下 install
4.回到 linux shell 重啟 httpd
驗證方式:
5.透過 shell 語法測試是否有啟動成功: ps -eaf | grep memcached
6.php info 也可以看到 memcache 已被載入中。
最後要注意的是,要低一點的apache版本,
才會看到memcache的選項。
(本篇教學由unethost.com客服撰寫)
延伸閱讀:如何備份Cpanel後台安裝的套裝程式?
安裝上述的軟體,我們提供虛擬主機試用,七天滿意保證,
功能完整使用不受限制,歡迎點我申請。
]]>
(1)安裝Remi repository (Fedora 12~17, RHEL 6不需要)
## Remi Dependency on CentOS and Red Hat (RHEL) rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
(2) 安裝memcached的軟体包(package)
如果是fedora 17/16/15/14/13/12或CentOS 6.3/6.2/6.1/6
yum install memcached
如果是 CentOS 5.8
yum --enablerepo=remi install memcached
(3) 設置memcached
vim /etc/sysconfig/memcached PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="512" OPTIONS=""
(4) 啟動memcached
# Set Memcached to start automatically on boot chkconfig memcached on # Start Memcached /etc/init.d/memcached start ## OR ## service memcached start
(5) 檢查memcached是否正常的運作。
echo stats | nc localhost 11211 STAT pid 7599 STAT uptime 10 STAT time 1265288542 STAT version 1.4.4 STAT pointer_size 32 STAT rusage_user 0.003999 STAT rusage_system 0.052991 STAT curr_connections 10 STAT total_connections 11 STAT connection_structures 11 STAT cmd_get 0 STAT cmd_set 0 STAT cmd_flush 0 STAT get_hits 0 STAT get_misses 0 STAT delete_misses 0 STAT delete_hits 0 STAT incr_misses 0 STAT incr_hits 0 STAT decr_misses 0 STAT decr_hits 0 STAT cas_misses 0 STAT cas_hits 0 STAT cas_badval 0 STAT auth_cmds 0 STAT auth_errors 0 STAT bytes_read 6 STAT bytes_written 0 STAT limit_maxbytes 536870912 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 4 STAT conn_yields 0 STAT bytes 0 STAT curr_items 0 STAT total_items 0 STAT evictions 0 END # Try to get some value echo get some_value | nc localhost 11211 END # Not found, but check the stats again echo stats | nc localhost 11211 STAT pid 7599 STAT uptime 10 STAT time 1265288542 STAT version 1.4.4 [...] STAT cmd_get 1 STAT cmd_set 0 STAT cmd_flush 0 STAT get_hits 0 STAT get_misses 1 STAT delete_misses 0 [...] STAT evictions 0 END
(6) 打開firewall
-A INPUT -m state --state NEW -m tcp -p tcp --dport 11211 -j ACCEPT
service iptables restart ## OR ## /etc/init.d/iptables restart
]]>
yum install php php-pecl-memcache
直接用yum install安裝,有時候會因為repo的問題而裝不起來。所以用tarball來裝,反而快。
Step 1 – 下載memcache
mkdir repo
cd repo
wget http://pecl.php.net/get/memcache-3.0.6.tgz
tar -xvfz memcache-3.0.6.tgz
Step 2 – 編繹 & 安裝
cd memcache-3.0.6
phpize
這時候,應該會看到類似的訊息:
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
./configure
make
make install
Step 3 – 修改php.ini
在php中,啟用memcache
echo "extension=memcache.so" >> /usr/local/lib/php.ini
service httpd restart