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://pecl.php.net/get/memcached
# MV Memcached memcached.tar.gz
# tar zxf memcached.tar.gz
# CD MEMCACHED-2.2.0B1/
# VI Php_libmemcached_compat.h
#ifndef Php_libmemcached_compat
#define Php_libmemcached_compat
19
/* 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
/usr/include/libmemcached/memcached.h

Then modify the path above to the normal path:

#ifndef Php_libmemcached_compat
#define Php_libmemcached_compat
19
/* 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
Cyrus-sasl-devel

Had to add the--DISABLE-MEMCACHED-SASL, again, but there are still errors:
#./configure--DISABLE-MEMCACHED-SASL
... Omitted...
In file included From/root/download/memcached-2.2.0b1/php_memcached_private.h:28,
FROM/ROOT/DOWNLOAD/MEMCACHED-2.2.0B1/PHP_MEMCACHED.C:26:
/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 https://launchpad.net/libmemcached/1.0/1.0.17/+download/libmemcached-1.0.17.tar.gz
# tar zxf libmemcached-1.0.17.tar.gz
# CD libmemcached-1.0.17
#./configure
# 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
/root/download/libmemcached-1.0.17/libmemcached/memcached.h
/root/download/libmemcached-1.0.17/libmemcached-1.0/struct/memcached.h
/root/download/libmemcached-1.0.17/libmemcached-1.0/memcached.h
/root/download/libmemcached-1.0.17/libtest/memcached.h
/root/download/mysql-5.6.15/plugin/innodb_memcached/daemon_memcached/daemon/memcached.h
/usr/local/include/libmemcached/memcached.h
/usr/local/include/libmemcached-1.0/struct/memcached.h
/usr/local/include/libmemcached-1.0/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
19
/* This is the version (s) We support * *
#include </usr/local/include/libmemcached/memcached.h>

5. Start compiling and installing PHP memcached extensions:

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

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

6. See if memcached.so has been generated:

# ls/usr/lib64/php/modules/
bcmath.so    gd.so        memcached.so         mysql.so       phar.so     sysvsem.so  xcache.so     xsl.so
curl.so       json.so      memcache.so           pdo_mysql.so   posix.so    sysvshm.so  xmlreader.so  zip.so
dom.so       mbstring.so  mysqli.so             pdo.so         sqlite3.so  tidy.so      xmlrpc.so
fileinfo.so  mcrypt.so    mysqlnd_memcache.so  pdo_ sqlite.so  sysvmsg.so  wddx.so     xmlwriter.so

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: info-contact@alibabacloud.com 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.