Installing PHP5 Memcache Extension Module on Ubuntu (note: you must have memcached installed prior to installing this extension module. refer to prerequisite install below):
-------------------------
# Prerequisite Install
-------------------------
# Download & install libevent (memcached dependency)
wget http://www.monkey.org/~provos/libevent-1.4.8-stable.tar.gz
tar xfz libevent-1.4.8-stable.tar.gz
cd libevent-1.4.8-stable
./configure && make && sudo make install
# Create a symlink to libevent
sudo ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib
# Download & install memcached
wget http://danga.com/memcached/dist/memcached-1.2.6.tar.gz
tar xfz memcached-1.2.6.tar.gz
cd memcached-1.2.6
./configure && make && sudo make install
# Run memcached as a daemon (d = daemon, m = memory, u = user, l = IP to listen to, p = port)
memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211
-------------------------
# PHP5-Memcache Install
-------------------------
# Download the extension module
apt-get install php5-memcache
# Edit /etc/php5/conf.d/memcache.ini and uncomment the following line by removing the semi-colon
extension=memcache.so
# Restart apache
/etc/init.d/apache2 restart
-------------------------
# Test Install
-------------------------
# Create a file 'memcache_test.php' in your webroot and paste the following:
<?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";
$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";
var_dump($get_result);
?>
# Test to see if the file renders in your browser
Cheers!
インストール手順
この » PECL 拡張 モジュールは PHP にバンドルされていません。 この PECL 拡張モジュールをインストールする方法は、 マニュアルの PECL 拡張モジュールのインストール という章にあります。 新規リリース・ダウンロード・ソースファイル・管理者情報・CHANGELOG といった関連する情報については、次の場所にあります。 » http://pecl.php.net/package/memcache.
注意: オプションで、memcache セッションハンドラのサポートを無効にすることもできます。 'pecl install' のオプションでこれを指定します (デフォルトは有効になっています) が、 PHP のコンパイル時に静的に組み込む場合は configure オプション --disable-memcache-session を使用できます。
インストール手順
djfobbz at gmail dot com
17-Sep-2008 04:11
17-Sep-2008 04:11
colnector on colnect.com
28-Aug-2008 03:59
28-Aug-2008 03:59
Forgot that small note: you might want to download memcached for Windows at http://jehiah.cz/projects/memcached-win32/ and install it either after or before installing the extention.
colnector on colnect.com
28-Aug-2008 03:44
28-Aug-2008 03:44
Windows installation is a bit more tricky since "pecl install memcache" does NOT work properly.
Here's how I installed it:
1/ Download pecl-5.2-dev.zip (choose the version relevant to your PHP) from http://snaps.php.net/
2/ Copy php_memcache.dll from the archive you've downloaded to your PHP extention folder.
3/ Add the following line to php.ini (in the exntentions section):
extension=php_memcache.dll
4/ Restart your server
5/ Check with phpinfo() that you now have a memcache section
Good luck :)
mykel dot alvis at gmail dot com
18-Jun-2008 03:01
18-Jun-2008 03:01
on Fedora, apparently
yum install php-pecl-memcache
akeem dot philbert at rokkan dot com
14-May-2008 01:30
14-May-2008 01:30
for ubuntu it is actually:
apt-get install php5-memcache
Anonymous
03-May-2008 10:20
03-May-2008 10:20
ubuntu:
apt-get install php5-memcached
the conf file is then in /etc/php5/cli/conf.d/memcache.ini
remember to restart the webserver
Wayne
01-May-2008 07:09
01-May-2008 07:09
Newer PHP versions don't have a --enable-memcache options; simply installing the PECL package will be enough... so to be absolutely clear, you WON'T have to recompile PHP to use memcache. That paragraph above seems like a bad case of earlier version documentation editing.
