源码下载地址: http://pan.baidu.com/s/1sj8rHpj
[root@ cq02 software]# tar -zxvf mysql-5.6.15.tar.gz
[root@ cq02 software]#cd mysql-5.6.15
[root@ cq02 mysql-5.6.15]# cmake -DCMAKE_INSTALL_PREFIX=/home/work/local/mysql-5.6.15
[root@ cq02 mysql-5.6.15]# make
[root@ cq02 mysql-5.6.15]# make install
[root@ cq02 mysql-5.6.15]# useradd mysql //添加 mysql 用户
[root@ cq02 mysql-5.6.15]# chown -R /home/work/local/mysql-5.6.15 .
[root@ cq02 mysql-5.6.15]# chgrp -R /home/work/local/mysql-5.6.15 .
[root@ cq02 mysql-5.6.15]# chown -R mysql /home/work/local/mysql-5.6.15
[root@ cq02 mysql-5.6.15]# ./home/work/local/mysql-5.6.15/bin/mysqld --user=mysql --basedir=/home/work/local/mysql-5.6.15 --datadir=/home/work/local/mysql-5.6.15/data/mysql --log-error=/home/work/local/mysql-5.6.15/data/ cq02.err --pid-file=/home/work/local/mysql-5.6.15/data/ cq02.pid --socket=/tmp/mysql_3308.sock --port=3308 //启动mysql,mysql安装完毕
[root@ cq02software]#tar -xzvf httpd-2.0.65.tar.gz
[root@ cq02 software]#cd httpd-2.0.65
[root@ cq02 httpd-2.0.65]# ./configure --prefix=/home/work/local/httpd --enable-module=so --enable-module=rewrite --enable-shared=max
[root@ cq02 httpd-2.0.65]#make & make install
[root@ cq02 httpd-2.0.65]#./home/work/local/httpd/bin/httpd -k start //启动apache
libxml2是一个xml的c语言版的解析器,不仅支持c语言,还支持c++、php、Pascal、Ruby、Tcl等语言的绑定
源码下载地址: http://pan.baidu.com/s/1pJM8Xz9
[root@ cq02 software]#tar -xzvf libxml2-sources-2.9.0.tar.gz
[root@ cq02 software]#cd libxml2-2.9.0
[root@ cq02 libxml2-2.9.0 ]#./configure --prefix=/home/work/local/libxml
[root@ cq02 libxml2-2.9.0 ]#make & make install
注:libmcrypt是加密算法扩展库。支持DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+等算法。
[root@ cq02 software]#tar -xzvf libmcrypt-2.5.5.tar.gz
[root@ cq02 software]#cd libmcrypt-2.5.5
[root@ cq02 libmcrypt-2.5.5]# ./configure --prefix=/home/work/local/libmcrypt
[root@ cq02 libmcrypt-2.5.5]#make & make install
源码下载地址: http://pan.baidu.com/s/1dDCebvV
[root@ cq02 software]#tar -xzvf php-5.2.17.tar.gz
[root@ cq02 software]#cd php-5.2.17
[root@ cq02 php-5.2.17]#./configure --prefix=/home/work/local/php --with-mysql=/home/work/local/mysql-5.6.15 --with-apxs2=/home/work/local/httpd/bin/apxs --with-libxml-dir=/home/work/local/libxml2 --with-config-file-path=/home/work/local/php/lib --enable-pdo=shared --with-sqlite=shared --with-pdo-sqlite=shared --with-zlib --enable-fastcgi --enable-mbstring=all --enable-pcntl --enable-sockets --enable-soap --enable-shmop --enable-exif --enable-sysvsem --enable-sysvshm --enable-sysvmsg --with-mcrypt=/home/work/local/libmcrypt --with-mysqli=/home/work/local/mysql-5.6.15/bin/mysql_config --with-mysql=/home/work/local/mysql-5.6.15
[root@ cq02 php-5.2.17]#make & make install
源码下载地址: http://pan.baidu.com/s/1i3KJrNZ
[root@ cq02 software]#tar -xzvf PDO_MYSQL-1.0.2.tgz
[root@ cq02 software]#cd PDO_MYSQL-1.0.2
[root@ cq02 PDO_MYSQL-1.0.2]#/home/work/local/php/bin/phpize
[root@ cq02 PDO_MYSQL-1.0.2]#./configure --with-php-config=/home/work/local/php/bin/php-config
[root@ cq02 PDO_MYSQL-1.0.2]#make & make install
pdo_mysql的全路径是:/home/work/local/php/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so
然后在/home/work/local/php/lib/php.ini 添加:
extension= pdo_mysql.so
接下来需要安装php memcached扩展,因为php_memcached是依赖libmemcached库,所以首先安装libevent、libmemcached库,需要安装libmemcached-1.x以上版本
[root@ cq02 software]#tar -xzvf libevent-2.0.12-stable.tar.gz
[root@ cq02 software]#cd libevent-2.0.12-stable.tar.gz
[root@ cq02 libevent-2.0.12-stable]#./configure --prefix=/home/work/local/libevent
[root@ cq02 libevent-2.0.12-stable]#make & make install
[root@ cq02 software]#tar -xzvf libmemcached-1.0.16.tar.gz
[root@ cq02 software]#cd libmemcached-1.0.16
[root@ cq02 libmemcached-1.0.16]#./configure --prefix=/home/work/local/libmemcached-1.0.16
[root@ cq02 libmemcached-1.0.16]#make & make install
[root@ cq02 software]#tar -xzvf memcached-2.1.0.tgz
[root@ cq02 software]#cd memcached-2.1.0
[root@ cq02 memcached-2.1.0]#/home/work/local/php/bin/phpize
[root@ cq02 memcached-2.1.0]#./configure --with-php-config=/home/work/local/php/
[root@ cq02 memcached-2.1.0]#make & make install
接下来在/home/work/local/php/lib/php.ini 中添加:extension=memcached.so
源码下载地址: http://pan.baidu.com/s/1ntkJvbb
[root@ cq02 software]#tar -xzvf memcached-1.4.20.tar.gz
[root@ cq02 software]#cd memcached-1.4.20
[root@ cq02 memcached-1.4.20]./configure --prefix=/home/work/local/memcached --with-libevent=/home/work/local/libevent
[root@ cq02 memcached-1.4.20]make & make install
持久化消息队列memcacheq是一个轻量级的消息队列。依附于Berkeley DB和libevent。Berkeley DB用于持久化存储队列的数据,避免在memcacheq出问题时造成数据丧失,接下来首先安装Berkeley DB
源码下载地址: http://pan.baidu.com/s/1eQw2Stc
[root@ cq02 software] tar -xzvf db-5.0.21.tar.gz
[root@ cq02 software]cd db-5.0.21
[root@ cq02 db-5.0.21]../dist/configure --prefix=/home/work/local/db-5.0.21
[root@ cq02 db-5.0.21]make & make install
源码下载地址: http://pan.baidu.com/s/1ntBNHpf
[root@ cq02 software] tar -xzvf memcacheq-0.2.0.tar.gz
[root@ cq02 software]cd memcacheq-0.2.0
[root@ cq02 memcacheq-0.2.0]./configure --prefix=/home/work/local/memcachedq --with-bdb=/home/work/local/db-5.0.21 --with-libevent=/home/work/local/libenvet
[root@ cq02 memcacheq-0.2.0]make & make install
[root@ cq02 memcacheq-0.2.0]./home/work/local/memcacheq/bin/memcacheq -d -uroot -l 10.57.16.37 -p 13000 -r -H /home/work/local/memcacheq/mcq_data -N -R -v -L 1024 -B 1024 //启动memcacheq消息队列
参数说明:
-d : 以后台服务方式运行
-l : 设置监听地址及端口(默认端口是22201)
-A : 数据页大小
-H : 数据保存目录 一定要存在
-B : 队列中每条数据的最大长度(字节)
-N : 使用内存缓冲方式保存数据至磁盘,从而获得极高性能。若无此参数,性能会很差
-R : 自动清理过期的日志 -u : 设置memcacheq进程账号
[root@ cq02 software]tar -xzvf phpredis-2.2.4.tar.gz
[root@ cq02 software]cd phpredis-2.2.4
[root@ cq02 phpredis-2.2.4]/home/work/local/php/bin/phpize
[root@ cq02 phpredis-2.2.4]./configure --with-php-config=/home/work/local/php/bin/php-config
[root@ cq02 phpredis-2.2.4]make & make install
然后在php.ini 中添加 extension= redis.so 并重启apache
如果启动时出现“memcached: error while loading shared libraries: libevent-2.0.so.5: cannotopen shared object file: No such file or directory”之类的信息,表示memcached 找不到libevent 的位置
所以,请先使用whereis libevent 得到位置,然后连接到memcached 所寻找的路径
首先查看,libevent 在哪里
[root@ cq02 software] whereis libevent
libevent: /home/work/local/libevent/lib/ libevent.la /home/work/local/libevent/lib/ libevent.so /home/work/local/libevent/lib/libevent.a
然后,再看memcached 从哪里找它
[root@ cq02 software] LD_DEBUG=libs memcached -v 2>&1 > /dev/null | less
可以看到:是/usr/lib/libevent-2.0.so.5,所以,创建软链
[root@ cq02 software] ln -s /home/work/local/libevent/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
再次启动.
通过源代码编译安装php的memcached扩展,一路顺利,最终生成了 memcached.so,同时在php.ini中添加了 extension= memcached.so,使用命令php -v查看时提示
PHP Warning: PHP Startup: Unable to loaddynamic library。后来发现是此机器的php.ini默认配置中使用了 extension_dir,解决办法就是注释掉php.ini中的extension_dir配置。