PECL Manual Install on Linux Centos

Just bought a VPS server hosting to play around from Media Temple. The Dedicated Virtual (DV) package come with Linux Centos, and all this while I’ve been a FreeBSD user, think it shouldn’t be hard to use Linux 😀 Sorry I’m a n00b on Linux.

yum is fun, I did yum install memcache and yum install php-pecl-memcache. memcache daemon service started successfully but php-pecl-memcache ain’t working.

memcache.ini is included in /etc/php.d/ and from phpinfo(), I can clearly seen memcache.ini is included as well. But, when I search for memcache module info, the module seem not loaded with into php.

memcache-ini

I remove php-pecl-memcache and tried to install with pecl install memcache, not good, pecl install were not working and the error message;


shell> pecl install memcache
downloading memcache-2.2.5.tgz ...
Starting to download memcache-2.2.5.tgz (35,981 bytes)
..........done: 35,981 bytes
11 source files, building
running: phpize
Configuring for:
PHP Api Version:         xxxxx
Zend Module Api No:      xxxxx
Zend Extension Api No:   xxxxx
 1. Enable memcache session handler support? : yes

1-1, 'all', 'abort', or Enter to continue: 
building in /var/tmp/pear-build-root/memcache-2.2.5
running: /var/cache/php-pear/memcache-2.2.5/configure --enable-memcache-session=yes
checking for egrep... grep -E
checking for a sed that does not truncate output... //bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
ERROR: `/var/cache/php-pear/memcache-2.2.5/configure --enable-memcache-session=yes' failed

Search for the error message, and it seem like it’s something to do with mount point permission for /var or /var/tmp partition.

Not wanting to do much on un-mount and re-mount the drive, I tried to install php-pecl-memcache manually.

Manual Compile PECL Extension with phpize

I will take memcahe as PECL extension for example, first I need to download the package file from PECL website, untar it and start compiling


shell> wget http://pecl.php.net/get/memcache-2.2.5.tgz
shell> tar zxfv memcache-2.2.5.tgz
shell> cd memcache-2.2.5 && phpize && ./configure && make && make install

After the installation, create memcahe.ini in /etc/php.d/


; Enable memcache extension module
extension=memcache.so

; Options for the memcache module

; Whether to transparently failover to other servers on errors
memcache.allow_failover=1
; Defines how many servers to try when setting and getting data.
memcache.max_failover_attempts=20
; Data will be transferred in chunks of this size
memcache.chunk_size=8192
; The default TCP port number to use when connecting to the memcached server 
memcache.default_port=11211
; Hash function {crc32, fnv}
memcache.hash_function=crc32
; Hash strategy {standard, consistent}
memcache.hash_strategy=standard

Restart apache webserver with /etc/init.d/httpd restart and write a phpinfo() file, now I can see memcache module is loaded

memcache-info

Anyone have the same error like I do and you have other workaround, please do let me know. Or change the permission on /etc/mtab 🙂

Need to get familiar with Linux Centos…