Ubuntu下面安装gearman以及php的gearman扩展是需要注意一下的。
不是默认的安装就直接OK
apt-get install gearman
安装完gearman后。使用pecl install gearman安装。这时候会提示你安装新版 的libgearman
如果你直接搜索apt-cache search libgearman,会发现有很多,但其实一个都不是。。不用上当了
OK,怎么办?有人也问过这个问题:http://stackoverflow.com/questions/13312207/installing-gearman-php-extension-on-debian-6
有人这么回复 :
The reason that this doesn't work is that as the error message says, the most recent version of the PHP extension requires libgearman-1.0 (which is why the directory is named 1.0). You'll need to be at least on wheezy (which is the version after debian 6 / squeeze) to get libgearman-1.0.
It might also be a solution to compile libgearman from source, and then use checkinstall
to create a debian package that you install afterwards, or use the gearman developer ppa available at https://launchpad.net/~gearman-developers/+archive/ppa
. We've built libgearman, gearmand and the PHP extension on a wide variety of distributions (including Debian, Ubuntu, RHEL4 and SL6) and used checkinstall to get a proper package available.
嗯,打开这个网址。
在最上面有提醒你怎么将PPA将入源里:
Adding this PPA to your system
You can update your system with unsupported packages from this untrusted PPA by adding ppa:gearman-developers/ppa to your system's Software Sources. (Read about installing)
OK,那我们开始吧:
apt-add-repository ppa:gearman-developers/ppa
然后,你根据你的版本,将源加到你的source.list文件里:
vim /etc/apt/source.list
加入:
deb http://ppa.launchpad.net/gearman-developers/ppa/ubuntu precise main deb-src http://ppa.launchpad.net/gearman-developers/ppa/ubuntu precise main
然后:apt-get update
apt-get upgrade
会提醒你需要升级gearman到最新版 本
这时候再:
pecl install gearman
然后就直接安装成功,会提示你怎么操作:XML/HTML代码
- Build process completed successfully
- Installing '/usr/lib/php5/20090626+lfs/gearman.so'
- install ok: channel://pecl.php.net/gearman-1.1.1
- configuration option "php_ini" is not set to php.ini location
- You should add "extension=gearman.so" to php.ini
按照提示操作完后,重启apache。
在命令行下执行:XML/HTML代码
- # php -i |grep gearman
- gearman
- gearman support => enabled
- libgearman version => 0.40
wow...安装成功。
就是这么简单
这是来自iOrange.cc的文章,主要就讲了两个可能会被常用的时间函数。内容如下:
按时间搜索数据在mysql里应该是用的比较频繁的了。
iOrange系统里的时间都是按:xxxx-xx-xx xx:xx:xx这种格式存放的,大多数时候这个都没问题,但是,当你想使用其他格式来显示数据时就悲剧了,例如你想显示成 10/04/01 21:20 这种就很悲剧-__-,所以强烈建议保存时间戳的时候尽量存储一个UNIX时间戳,这样以后就方便很多了^_^
回归正题,第一个时间函数是:UNIX_TIMESTAMP,这个函数可以将xxxx-xx-xx xx:xx:xx这种格式的时间转换成一个unix时间戳格式的数字。例如下面那条语句:
update bookposts set lastpost = UNIX_TIMESTAMP(createdate) 这样就能将createdate字段上的时间更新到lastpost上去了。
第二个函数则跟第一个刚好相反:FROM_UNIXTIME,这个函数可以将一个UNIX时间戳转换成xxxx-xx-xx xx:xx:xx这种格式。用法大致如下:
SELECT COUNT(*) AS `newmembers` FROM `cdb_members` WHERE FROM_UNIXTIME(regdate, ‘%Y-%m-%d’) = ‘2010-04-01′”
--EOF--
不过,个人认为还是采用:xxxx-xx-xx xx:xx:xx比较好,这是因为,时间戳和这种日期格式在数据库里存储所占的字节都是一样的,而日期格式却没有1970~2038年这个限制。在计算时间区间的时候,用Between和and时,对于日期格式会更加方便,而时间戳则需要多计算一次。
参考:
1.Mysql时间函数 http://neatstudio.com/show-443-1.shtml
2.用TIMESTAMP类型取代INT和DATETIME[转] http://neatstudio.com/show-150-1.shtml
3.精通MYSQL数据库——连载八 http://neatstudio.com/show-263-1.shtml