9

I built PHP from source with configure command

'./configure' '--prefix=/usr/local/php-5.2.8' '--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d' '--with-apxs2=/usr/local/httpd/bin/apxs' '--with-mysql=/usr/local/mysql/' '--with-zlib' 

I installed php memcache extension :

wget http://pecl.php.net/get/memcache
tar -zxvf memcache-2.2.5.tgz
cd memcache-2.2.5
phpize
./configure --enable-memcache
make
make install

I add to my /usr/local/lib/php.in

extension=memcache.so

Rebooted my apache and run php-m but php seem doesn't load memcache extension I followed this solution from this site http://www.howtoforge.com/forums/showthread.php?t=26554

I added full path

extension=/usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so 

rebooted apache But it didn't load memcache extension ! I google around but the same issue ! How can I load this extension _ _"

8 Answers 8

1

Firstly run your php binary like

php -v

It should complain that your php.ini wants to load modules that cant be loaded...

If it doesnt complain, run

php --ini

This should give you the location of your php.ini ( just incase your editing the wrong one :D )

Did this help?

1

The problem is..., at this point: wget http://pecl.php.net/get/memcache Instead of tar -zxvf memcache-2.2.5.tgz, you should do tar -zxvf memcache (this is the filename from wget).

After you extract the file, you will get the latest version of memcache, at the time I do this, I get the folder memcache-3.0.8.

So, the next steps will be:

cd memcache-3.0.8 
phpize 
./configure --enable-memcache 
make
make install

And finally , dont forget to add this line to your php.ini:

extension = memcache.so

And restart Apache.

0

Are you sure memcached is installed in the correct location? What do you get if you run: locate memcache.so

Is memcached installed (the binary)? Does it require any extra libraries (libmemcache)?

2
  • You should use find, not locate, given that it may not yet be in the locate db.
    – Cian
    Sep 14, 2009 at 11:33
  • The memcached daemon is installed successfull! and when I locate the memcache extension locate memcache.so /usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so /usr/local/src/memcache-2.2.5/.libs/memcache.so /usr/local/src/memcache-2.2.5/modules/memcache.so I think the problem is php didn't load the extension !
    – billyduc
    Sep 15, 2009 at 2:39
0

Add an extension_dir directive to tell PHP where to load extensions from and remove the path from the extension directive.

extension = memcache.so
extension_dir = /usr/local/lib/php/extensions/no-debug-non-zts-20060613
1
  • poor me ! It doesn't work !
    – billyduc
    Sep 30, 2009 at 4:00
0

One thing that helped me is to use

pecl uninstall memcache
pecl install memcache

Another thing (this applies only to rather old php versions though): http://www.hollub.at/phpmanual/ref.memcache.html says:

In order to use these functions you must compile PHP with Memcache support by using the --enable-memcache[=DIR] option. 
0

this is because of your /var/tmp mounted with noexec permission

you can try to recompile memcache using fuenfundachtzig command after temporarily delete /var/tmp symlink and create new /var/tmp folder. (this setting maybe differ from your server)

#rm /var/tmp
#mkdir /var/tmp

#pecl install memcache

then secure back your temp folder

#rm -rf /var/tmp
#ln -s /tmp /var/tmp

read more about securing tmp here

and how to use PECL with tmp mounted with noexec

0

If you have your PHP compiled, try to remove extension_dir from your php.ini.

0

NOTE: this installs "memcache.so" not "memcached.so"

The problem probably is, that you create a memcache.so with phpize that is for another php-version than you are using. phpize always compiles for the latest php version.

install

apt install php8.1-dev

then you have the version of phpize with

phpize8.1 -v

download and compile memcache:

mkdir memcache-install
cd memcache-install/
wget http://pecl.php.net/get/memcache
mv memcache memcache.tgz
unp memcache.tgz
cd memcache-8.0
phpize8.1
./configure --enable-memcache
make
make install

Alternatively you can get the phpize version by downloading the php-version you want, unpack it, compile and usethe phpize version from there:

check your version:

dpkg -l|egrep 'php8.1\s'

in my case: 8.1.18

on https://www.php.net/downloads.php download

wget https://www.php.net/distributions/php-8.1.18.tar.gz
unp php-8.1.18.tar.gz
cd php-8.1.18/
apt install build-essential autoconf libtool bison re2c pkg-config libxml2-dev
./buildconf
./configure --enable-cli --without-sqlite3 --without-pdo-sqlite
make -j $(nproc)

The compiled binaries will be available in the ./sapi directory:

./sapi/cli/phpize -v

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .