编译安装libevent,memcache,以及php的memcached扩展
一 安装libevent
1.去官网http://libevent.org/ 下载最新源码,我用的是libevent-2.0.20-stable.tar.gz
2.解压到/usr/src目录 ,执行命令:sudo tar -zxvf libevent-2.0.20-stable.tar.gz -C /usr/src
3.进入解压以后的目录,用sudo方式执行命令:sudo ./configure --prefix=/usr/local/libevent ; make ; make install
二 安装memcache
1.去官网 http://memcached.org/ 下最新源码,我用的是memcached-1.4.15.tar.gz
2.解压到/usr/src目录 ,执行命令:sudo tar -zxvf memcached-1.4.15.tar.gz -C /usr/src
3.进入解压以后的目录,用sudo方式执行命令:sudo ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent; make ; make install
三 安装php的memcache扩展
有两个版本一个是memcache(http://pecl.php.net/package/memcache ),另一个是基于libmemcached的memcached版本(http://pecl.php.net/package/memcached );
网上查的资料是说前一个是原生的,后一个比前一个功能更强大。比较推荐使用基于libmemcahced 库的memcached扩展。支持memcache提供的CAS操作,稳定性和效率也更好。
这里我使用基于libmemcached 库的memcached扩展,安装步骤如下:
首先,安装libmemcached库
1.去网址 https://launchpad.net/libmemcached (或者http://libmemcached.org/libMemcached.html )下载源码,
我用的是libmemcached-1.0.14.tar.gz
2.解压缩到/usr/src目录,用sudo方式执行命令:sudo tar -zxvf libmemcached-1.0.14.tar.gz -C /usr/src
3.进入目录/usr/src/libmemcached-1.0.14/,sudo方式执行命令:./configure ;make;make install (不加--prefix=/usr/local/libmemcached 指定安装目录时,libmemcached 默认安装在/usr/local/,头文件安装在/usr/local/include/libmemcachde/,动态库默认安装在/usr/local/lib/下。)
4.make时遇到问题:sorry, unimplemented: Graphite loop optimizations can only be used if the libcloog-ppl0 package is installed。解决办法是修改Makefile,查找并去掉 floop-parallelize-all(应该有两处需要去掉),看了网上资料说是去掉后表示不使用Graphite loop 优化。
5.再次make,遇到问题:fatal error: sasl/sasl.h: No such file or directory. 在网上搜到的解决办法是:
Depending on your operating system, you'll need to install the cyrus-sasl development package.
That would be cyrus-sasl-devel on RedHat based distros and libsasl2-dev on Debian based distros IIRC.
我在ubuntu下直接用sudo apt-get install libsasl2-dev 安装了。
6.编译还是遇到问题,显示无法链接到sasl的一些文件。问题显示如下:
undefined reference to `sasl_client_step'
undefined reference to `sasl_dispose'
undefined reference to `sasl_client_start'
undefined reference to `sasl_client_new'
解决办法是重新执行configure命令,增加相应的参数。sudo执行命令:sudo ./configure --enable-sasl --without-memcached LDFLAGS=-Wl,--as-neede ;make; make install
7.终于安装libmemcached库成功了。。。
其次,安装memcached版本的php扩展
1. 去网址http://pecl.php.net/package/memcached 下载memcached版本,我用的是memcached-2.1.0.tgz
2. 解压到/usr/src目录 ,执行命令:sudo tar -zxvf memcached-2.1.0.tgz -C /usr/src
3. 进入解压以后的目录,是没有configure文件的,用sudo方式执行命令来生成:sudo /usr/local/php/bin/phpize
4.遇到问题:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. 网上搜到的解决办法为:
cd /usr/src wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz tar -zvxf m4-1.4.9.tar.gz cd m4-1.4.9/ ./configure && make && make install cd ../ wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz tar -zvxf autoconf-2.62.tar.gz<br>cd autoconf-2.62/ ./configure && make && make install
5.这是再次执行sudo /usr/local/php/bin/phpize,就可以成功生成configure文件了。(phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块,官方说明网址为:http://php.net/manual/en/install.pecl.phpize.php)
6.用sudo方式执行命令./configure --with-php-config=/usr/local/php/bin/php-config; make ; make install
7.编译完成了,还需要做的是在/usr/local/lib/php.ini文件中加入extension值:extension=memcache.so
8.重启/usr/local/php/sbin/php-fpm程序使配置生效,但是报错:
ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)
ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'
ERROR: FPM initialization failed
解决办法为: (1)cd /usr/local/php/etc/; (2)mv php-fpm.conf.default php-fpm.conf
9.重启仍然出现问题:ERROR: [pool www] cannot get uid for user 'www'。解决办法为:编辑文件vim /usr/local/php/etc/php-fpm.conf,
把user = nobody group = nobody 中的nobody修改成有效的用户和用户组名称。
10.php扩展可使用的一些方法可参考网址:http://blog.csdn.net/fwkjdaghappy1/article/details/7592337
参考网址:
http://www.dewen.org/q/844
http://hi.baidu.com/thinkinginlamp/item/5a3b2531e25dc6f62784f4fb
http://code.google.com/p/memcached/wiki/PHPClientComparison
https://bugs.launchpad.net/keystone/+bug/843080
http://www.cppblog.com/kefeng/archive/2010/10/11/129422.html
https://bugs.launchpad.net/libmemcached/+bug/656010
http://blog.csdn.net/vaal_water/article/details/6439483
http://www.spiration.co.uk/post/1385/Cannot-find-autoconf.-Please-check-your-autoconf-installation
https://gist.github.com/3359828
http://www.2cto.com/kf/201111/110140.html
http://blog.johntechinfo.com/technology/264
http://www.oschina.net/question/231397_36921
http://www.cnblogs.com/huangjingzhou/articles/2093706.html
http://blog.csdn.net/fwkjdaghappy1/article/details/7592337

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Python is an ideal programming introduction language for beginners through its ease of learning and powerful features. Its basics include: Variables: used to store data (numbers, strings, lists, etc.). Data type: Defines the type of data in the variable (integer, floating point, etc.). Operators: used for mathematical operations and comparisons. Control flow: Control the flow of code execution (conditional statements, loops).

Java Made Simple: A Beginner's Guide to Programming Power Introduction Java is a powerful programming language used in everything from mobile applications to enterprise-level systems. For beginners, Java's syntax is simple and easy to understand, making it an ideal choice for learning programming. Basic Syntax Java uses a class-based object-oriented programming paradigm. Classes are templates that organize related data and behavior together. Here is a simple Java class example: publicclassPerson{privateStringname;privateintage;

Java is a popular programming language that can be learned by both beginners and experienced developers. This tutorial starts with basic concepts and progresses through advanced topics. After installing the Java Development Kit, you can practice programming by creating a simple "Hello, World!" program. After you understand the code, use the command prompt to compile and run the program, and "Hello, World!" will be output on the console. Learning Java starts your programming journey, and as your mastery deepens, you can create more complex applications.

Pythonempowersbeginnersinproblem-solving.Itsuser-friendlysyntax,extensivelibrary,andfeaturessuchasvariables,conditionalstatements,andloopsenableefficientcodedevelopment.Frommanagingdatatocontrollingprogramflowandperformingrepetitivetasks,Pythonprovid
