您好,登錄后才能下訂單哦!
本篇內容介紹了“CentOS下PHP安裝memcache擴展問題的解決方法”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
系統版本是5.2,把安裝memcached的方法記錄下先:
代碼如下:
cd ~/memcached
wget -c http://www.monkey.org/~provos/libevent-1.4.10-stable.tar.gz
wget -c http://memcached.googlecode.com/files/memcached-1.2.8.tar.gz
#安裝libevent
tar -zxvf libevent-1.4.10-stable.tar.gz
cd libevent-1.4.10-stable
./configure
make
make install
#安裝memcached
cd ..
tar -zxvf memcached-1.2.8.tar.gz
cd memcached-1.2.8
./configure
make
make install
#如果是64位系統,還需要把libevent的文件復制到/wp-content/lib64/下,用來解決error while loading shared libraries的問題
cp -R /wp-content/local/lib/libevent* /wp-content/lib64/
好了,開始安裝php的擴展,惡夢開始了,本以為直接用yum來安裝php-devel.x86_64和php-pecl-memcache.x86_64這兩個擴展就可以了,可裝了后 phpinfo()里根本找不到memcache擴展,把已經裝的這兩個擴展remove重來,還是不行,goooooooooooooogle,找到了一篇文章《PHP Pecl Memcached module installation problems》,有救嘍,先remove掉php-pecl-memcache.x86_64,然后執行了
pecl install memcache
順利安裝上了,打開/etc/php.d/看了下,沒有memcache.ini,好吧,手動到/etc/php.ini加上了 extension=memcache.so,好了,重啟httpd,刷新 phpinfo() ,竟然還沒有,我郁悶了。。
回頭想想,我好像漏了一個地方沒有檢查,馬上打開 /wp-content/lib64/php/modules/ 查看,果然沒有memcache.so,會在哪呢? find -name之,原來躲在 /wp-content/local/lib/php/extensions/no-debug-non-zts-20060613/ 下,復制到 /wp-content/lib64/php/modules/ 再試,久違的 memcache擴展出現了。 T T
Memcached參數說明:
-d選項是啟動一個守護進程
-m分配給Memcache使用的內存數量,單位是MB
-u運行Memcache的用戶
-l監聽的服務器IP地址
-p設置Memcache監聽的端口,最好是1024以上的端口
-c最大運行的并發連接數,默認是1024,按照你服務器的負載量來設定
-P設置保存Memcache的pid文件
啟動:
memcached -d -u root -m 128 -c 8192
查看狀態:
watch “echo stats | nc 127.0.0.1 11211″
狀態說明:
uptime:memcached運行的秒數
cmd_get:查詢緩存的次數。這兩個數據相除一下就能得到平均每秒請求緩存的次數
cmd_set:設置key=>value的次數
get_hits:緩存命中的次數。緩存命中率 = get_hits/cmd_get * 100%
scurr_items:現在在緩存中的鍵值對個數
相關網址:
Libevent:http://www.monkey.org/~provos/libevent/
Memcached:http://danga.com/memcached/
PHP Memcached Extension:http://pecl.php.net/package/memcache
undefined
[shell]
[root@~]# pecl install memcache
downloading memcache-2.2.6.tgz ...
Starting to download memcache-2.2.6.tgz (35,957 bytes)
..........done: 35,957 bytes
11 source files, building
WARNING: php_bin /opt/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
Enable memcache session handler support? [yes] : n
[/shell]
[shell]
running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-memcache-2.2.6" install
Installing shared extensions: /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib/php/extensions/no-debug-non-zts-20090626/
running: find "/var/tmp/pear-build-root/install-memcache-2.2.6" | xargs ls -dils
11370548 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6
11370602 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt
11370603 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php
11370604 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib
11370605 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib/php
11370606 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib/php/extensions
11370607 4 drwxr-xr-x 2 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib/php/extensions/no-debug-non-zts-20090626
11370601 236 -rwxr-xr-x 1 root root 235639 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so
Build process completed successfully
Installing '/opt/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so'
install ok: channel://pecl.php.net/memcache-2.2.6
configuration option "php_ini" is not set to php.ini location
You should add "extension=memcache.so" to php.ini
[/shell]
“CentOS下PHP安裝memcache擴展問題的解決方法”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。