php中應用memcached

來源:互聯網
上載者:User

標籤:pat   應用   value   bug   memcach   測試   擴充   usr   config   

PHP串連Memcached
先安裝php的memcache擴充
# wget  http://ip/data/attachment/forum/memcache-2.2.3.tgz
# tar zxf memcache-2.2.3.tgz 
# cd memcache-2.2.3
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
安裝完後會有類似這樣的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
把這個記住,然後修改php.ini,把 extension_dir = "./"
修改為extension_dir = "/usr/local/servers/php5/lib/php/extensions/no-debug-non-zts-20090626/"
並添加一行extension="memcache.so"
PHP串連Memcached 檢驗
/usr/local/php/bin/php -m |grep memcache
下載測試php指令碼 curl ip/study_v2/.memcache.txt > 1.php 2>/dev/null/usr/local/php/bin/php 1.php
Memcached 實現session共用
本執行個體是在lamp/lnmp環境下實現編輯php.ini添加兩行
session.save_handler = memcache 
session.save_path = "tcp://192.168.0.9:11211" 
或者httpd.conf中對應的虛擬機器主機中添加
php_value session.save_handler "memcache" 
php_value session.save_path "tcp://192.168.0.9:11211" 
或者php-fpm.conf對應的pool中添加php_value[session.save_handler] = memcache
php_value[session.save_path] = " tcp://192.168.0.9:11211 "

Memcached session測試
wget http://ip/.mem_se.txtmv .mem_se.txt
/usr/local/apache2/htdocs/session.phpcurl localhost/session.php
類似於1443702394<br><br>1443702394<br><br>i44nunao0g3o7vf2su0hnc5440
telnet 127.0.0.1 11211
get i44nunao0g3o7vf2su0hnc5440

php中應用memcached

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.