Solve the problem of compiling PHP memcached extensions: PHP

Source: Internet
Author: User
Tags install php memcached php memcached

This article introduces you to solve the problem of compiling PHP memcached extensions: php_libmemcached_compat.h:5:40: Error: libmemcached-1.0/ Memcached.h: Without that file or directory, I hope the article will help you.


The server is CENTOS6 64,php5.4.23, and you need to install the PHP memcached extension

Attempt to install using PECL:
# yum Install libmemcached libmemcached-devel zlib-devel
# yum-y Install Php-pear
# pecl Install memcached

But an error occurred:
In the file containing the/var/tmp/memcached/php_memcached.h:22, from/var/tmp/memcached/php_memcached.c:47:
/VAR/TMP/MEMCACHED/PHP_LIBMEMCACHED_COMPAT.H:5:40: Error: libmemcached-1.0/memcached.h: no file or directory

The above obvious php_libmemcached_compat.h file can not find the memcached.h, so download the package, a look at the following:
# wget Http://
# MV Memcached memcached.tar.gz
# tar zxf memcached.tar.gz
# VI Php_libmemcached_compat.h
#ifndef Php_libmemcached_compat
#define Php_libmemcached_compat
/* This is the version (s) We support * *
#include <libmemcached/memcached.h>

See above contains libmemcached/memcached.h, but in fact memcached.h files are located at:
# Find/usr-name Memcached.h

Then modify the path above to the normal path:

#ifndef Php_libmemcached_compat
#define Php_libmemcached_compat
/* This is the version (s) We support * *
#include </usr/include/libmemcached/memcached.h>

After saving, use Phpize to compile:

Configure:error:no, Sasl.h is not available. Run Configure with--DISABLE-MEMCACHED-SASL to disable this check

Had to add the--DISABLE-MEMCACHED-SASL, again, but there are still errors:
... Omitted...
In file included From/root/download/memcached-2.2.0b1/php_memcached_private.h:28,
/ROOT/DOWNLOAD/MEMCACHED-2.2.0B1/PHP_LIBMEMCACHED_COMPAT.H:53: Error: expected ' = ', ', ', '; ', ' asm ' or ' __attribute__ ' Before ' Php_memcached_instance_st '
... Omitted...

It seems blocked, only manually compiled libmemcached to try.

The following is a manual compilation of libmemcached and PHP memcached extensions

1. Uninstall the libmemcached of the Yum installation first

# yum Remove libmemcached libmemcached-devel

2. Download the source package

# CD ...
# wget
# tar zxf libmemcached-1.0.17.tar.gz
# CD libmemcached-1.0.17
# make
# make Install

Successfully installed libmemcached.

3. Next install memcached, first find memcached.h header file where, need to set the correct include path in php_libmemcached_compat.h

# CD ... /memcached-2.2.0b1
# Find/-name Memcached.h

4. Modify the include path in the Php_libmemcached_compat.h file under Memcached-2.2.0b1 to the correct path:

#ifndef Php_libmemcached_compat
#define Php_libmemcached_compat
/* This is the version (s) We support * *
#include </usr/local/include/libmemcached/memcached.h>

5. Start compiling and installing PHP memcached extensions:

# phpize
# make
... Omitted...
Build complete.
Don ' t forget to run ' make test '.

# make Install
Installing Shared extensions:/usr/lib64/php/modules/

6. See if has been generated:

# ls/usr/lib64/php/modules/      pdo_

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

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.