好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

PHP消息队列httpsqs安装与使用教程

PHP消息队列httpsqs安装与使用教程

项目网址:http://code.google.com/p/httpsqs/

使用文档:http://blog.s135.com/httpsqs/

说明:由于需要安装的东西有些多,原文可能写的有些简略,所以适当补充了

 

1.安装libevent-2.0.12-stable.tar.gz

wget http://httpsqs.googlecode.com/files/libevent-2.0.12-stable.tar.gz
tar zxvf libevent-2.0.12-stable.tar.gz
cd libevent-2.0.12-stable/  
./configure --prefix=/usr/local/libevent-2.0.12-stable/  
make  
make install  
cd 

2.安装tokyocabinet-1.4.47.tar.gz

wget http://httpsqs.googlecode.com/files/tokyocabinet-1.4.47.tar.gz  
tar zxvf tokyocabinet-1.4.47.tar.gz  
cd tokyocabinet-1.4.47/  
./configure --prefix=/usr/local/tokyocabinet-1.4.47/  
#注:在32位Linux操作系统上编译Tokyo cabinet,请使用./configure --enable-off64代替./configure,可
以使数据库文件突破2GB的限制。  
#./configure --enable-off64 --prefix=/usr/local/tokyocabinet-1.4.47/  
make  
make install  
cd 

当执行第二步骤的会出错,是由于缺少bzip2-1.0.6.tar.gz

下面进行安装

http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz安装开始;  
wget  http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz  
tar -xvzf bzip2-1.0.6.tar.gz  
cd bzip2-1.0.6.  
make  
 make install

在重复安装tokyocabinet-1.4.47.tar.gz还是失败,由于缺少zlib-1.2.5.tar.gz

下面进行安装

http://www.winimage.com/zLibDll/zlib-1.2.5.tar.gz安装开始;  
wget  http://www.winimage.com/zLibDll/zlib-1.2.5.tar.gz  
tar -xvzf zlib-1.2.5.tar.gz  
cd zlib-1.2.5.  
./configure  
make  
sudo make instal

3.安装httpsqs-1.7.tar.gz

wget http://httpsqs.googlecode.com/files/httpsqs-1.7.tar.gz  
tar zxvf httpsqs-1.7.tar.gz  
cd httpsqs-1.7/  
make  
make install  
cd 

4.测试

如果安装成功 执行httpsqs –h 会出现

------------------------------------------------------------------------------------------------

--  

HTTP Simple Queue Service - httpsqs v1.7 (April 14, 2011)  
  
  
Author: Zhang Yan (http://blog.s135.com), E-mail: net@s135.com  
This is free software, and you are welcome to modify and redistribute it under the New BSD
License  
  
  
-l <ip_addr>  interface to listen on, default is 0.0.0.0  
-p <num>      TCP port number to listen on (default: 1218)  
-x <path>     database directory (example: /opt/httpsqs/data)  
-t <second>   keep-alive timeout for an http request (default: 60)  
-s <second>   the interval to sync updated contents to the disk (default: 5)  
-c <num>      the maximum number of non-leaf nodes to be cached (default: 1024)  
-m <size>     database memory cache size in MB (default: 100)  
-i <file>     save PID in <file> (default: /tmp/httpsqs.pid)  
-a <auth>     the auth password to access httpsqs (example: mypass123)  
-d            run as a daemon  
-h            print this help and exit

 

5.设置

存储目录

#mkdir /usr/local/httpsqs_queue
mkdir /home/bf
vi /home/bf/httpsqs.sh
内容如下:
#! /bin/sh
ulimit -SHn 65535
启动方法
带密码
# /usr/bin/httpsqs -d -p 1218 -t 10 -c 10000 -m 512 -x /usr/local/httpsqs_queue -a pwd123
无密码
# /usr/bin/httpsqs -d -p 1218 -t 10 -c 10000 -m 512 -x /usr/local/httpsqs_queue
干掉的方法
# killall httpsqs

 

7.php扩展

参考:http://code.google.com/p/php-httpsqs-client/

安装说明

# mkdir php_httpsqs_client 
# cd php_httpsqs_client 
# wget http://php-httpsqs-client.googlecode.com/files/php_httpsqs_client_0.2.1.tar.gz
# tar vzxf php_httpsqs_client_0.2.1.tar.gz
# /usr/local/php/bin/phpize

查看更多关于PHP消息队列httpsqs安装与使用教程的详细内容...

  阅读:55次