从源码安装apache2,遇到错误:cannot install `libaprutil-1.la'

开源技术采菊篱下 回复了问题 • 1 人关注 • 1 个回复 • 798 次浏览 • 2015-06-14 11:34 • 来自相关话题

apache启动报错(98)Address already in use: make_sock: could not bind to address [::]:80

开源技术采菊篱下 回复了问题 • 1 人关注 • 1 个回复 • 865 次浏览 • 2015-06-14 11:32 • 来自相关话题

Cannot load /…/libphp5.so into server: /…/libphp5.so: undefined symbol: _efree

开源技术采菊篱下 回复了问题 • 1 人关注 • 1 个回复 • 825 次浏览 • 2015-06-14 11:29 • 来自相关话题

批量删除Redis数据库中的Key

数据库OpenSkill 发表了文章 • 0 个评论 • 753 次浏览 • 2015-06-14 11:04 • 来自相关话题

批量删除Key
Redis 中有删除单个 Key 的指令 DEL,但好像没有批量删除 Key 的指令,不过我们可以借助 Linux 的 xargs 指令来完成这个动作redis-cli keys "*" | xargs redis-cli del
//如果redis-cli没有设置成系统变量,需要指定redis-cli的完整路径
//如:/opt/redis/redis-cli keys "*" | xargs /opt/redis/redis-cli del
如果要指定 Redis 数据库访问密码,使用下面的命令redis-cli -a password keys "*" | xargs redis-cli -a password del
删除所有Key
删除所有Key,可以使用Redis的flushdb和flushall命令//删除当前数据库中的所有Key
flushdb
//删除所有数据库中的key
flushall
注:keys 指令可以进行模糊匹配,但如果 Key 含空格,就匹配不到了,暂时还没发现好的解决办法。
参考文档:http://stackoverflow.com/questions/5756067/how-to-empty-a-redis-database 查看全部
批量删除Key
Redis 中有删除单个 Key 的指令 DEL,但好像没有批量删除 Key 的指令,不过我们可以借助 Linux 的 xargs 指令来完成这个动作
redis-cli keys "*" | xargs redis-cli del  
//如果redis-cli没有设置成系统变量,需要指定redis-cli的完整路径
//如:/opt/redis/redis-cli keys "*" | xargs /opt/redis/redis-cli del

如果要指定 Redis 数据库访问密码,使用下面的命令
redis-cli -a password keys "*" | xargs redis-cli -a password del  

删除所有Key
删除所有Key,可以使用Redis的flushdb和flushall命令
//删除当前数据库中的所有Key  
flushdb
//删除所有数据库中的key
flushall

注:keys 指令可以进行模糊匹配,但如果 Key 含空格,就匹配不到了,暂时还没发现好的解决办法。
参考文档:http://stackoverflow.com/questions/5756067/how-to-empty-a-redis-database

centos 6.2 更新报错解决 yum you could try using skip broken to work around the problem

开源技术采菊篱下 回复了问题 • 1 人关注 • 1 个回复 • 1224 次浏览 • 2015-06-14 10:40 • 来自相关话题

编译apache错误 configure:error:libjpeg.(a|so) not found

开源技术采菊篱下 回复了问题 • 1 人关注 • 1 个回复 • 894 次浏览 • 2015-06-13 12:59 • 来自相关话题

Redis中key相关主要操作函数

数据库OpenSkill 发表了文章 • 3 个评论 • 815 次浏览 • 2015-06-13 12:31 • 来自相关话题

总结redis中跟key相关的常用函数
1)keys
语法:keys pattern
解释:查找所有匹配指定模式pattern的key[root@cjlx ~]# redis-cli
redis 127.0.0.1:6379> keys * #所有key
1) "score"
2) "stu"
3) "score1"
4) "dest"
5) "lst.user"
6) "lst.tect"
redis 127.0.0.1:6379> keys scor?
1) "score"
redis 127.0.0.1:6379> keys scor[ee1]
1) "score" 2)randomkey
语法:randomkey 
解释:返回一个随机keyredis 127.0.0.1:6379> randomkey
"score"
redis 127.0.0.1:6379> randomkey
"list.user" 3)exists
语法:exists key
解释:判断一个key是否存在redis 127.0.0.1:6379> exists score #key存在 返回1
(integer) 1
redis 127.0.0.1:6379> exists scorefda #key不存在 返回0
(integer) 0 4)type
语法:type key
解释:返回key所存储的值类型,返回值:none [key不存在],string,list ,set, zset和hashredis 127.0.0.1:6379> type score
zset
redis 127.0.0.1:6379> type lst.user
list 5)expire
语法:expire key seconds
解释:设置key的生存时间,单位是秒,当key过期时,会被自动删除redis 127.0.0.1:6379> expire dest 30
(integer) 1
redis 127.0.0.1:6379> expire dest1 30 # key不存在
(integer) 0 6)ttl
语法: ttl key
解释:得到key能存活时间,如果key不存在或没有设置生存时间时,返回-1redis 127.0.0.1:6379> expire diff 100
(integer) 1
redis 127.0.0.1:6379> ttl diff
(integer) 94
redis 127.0.0.1:6379> ttl diff
(integer) 92
7)persist
语法:persist key
解释:移除给定key的生存时间redis 127.0.0.1:6379> ttl diff
(integer) 28
redis 127.0.0.1:6379> persist diff
(integer) 1
redis 127.0.0.1:6379> ttl diff
(integer) -1 8)rename
语法:rename key newkey
解释:将key改名为newkeyredis 127.0.0.1:6379> smembers diff
1) "zhangsan01"
redis 127.0.0.1:6379> rename diff diff01
OK
redis 127.0.0.1:6379> smembers diff
(empty list or set)
redis 127.0.0.1:6379> smembers diff01
1) "zhangsan01"
redis 127.0.0.1:6379> rename diff diff01
(error) ERR no such key注意:当key和newkey相同或key不存在时,返回错误;当newkey已存在时,rename将覆盖旧值。
 
9)renamenx
语法:renamenx key newkey
解释:当且仅当newkey不存在时,改名keyredis 127.0.0.1:6379> renamenx diff01 stu #stu存在
(integer) 0
redis 127.0.0.1:6379> renamenx diff01 diff #diff不存在
(integer) 1 10)del
语法:del key [key ...]
解释:删除一个或多个keyredis 127.0.0.1:6379> del score1
(integer) 1
redis 127.0.0.1:6379> del union diff aa #key aa 不存在
(integer) 2 11)move
语法:move key db
解释:将key移动到指定dbredis 127.0.0.1:6379> smembers stu #默认0
1) "zhangsan01"
2) "wangwu"
redis 127.0.0.1:6379> move stu 1 #移动到 1
(integer) 1
redis 127.0.0.1:6379> smembers stu
(empty list or set)
redis 127.0.0.1:6379> select 1 #选择db 1
OK
redis 127.0.0.1:6379[1]> smembers stu
1) "zhangsan01"
2) "wangwu"12)sort
语法:sort key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]
解释:返回或保持给定列表,集合,有序集合key中经过排序的元素redis 127.0.0.1:6379> sort lst.tech limit 0 2 alpha desc #按字符集排序
1) "tec06"
2) "tec05"
redis 127.0.0.1:6379> sort lst.stud
1) "1"
2) "2"
3) "3"
redis 127.0.0.1:6379> sort lst.stud desc
1) "3"
2) "2"
3) "1"
redis 127.0.0.1:6379> keys stu.*
1) "stu.name.2"
2) "stu.name.3"
3) "stu.level.1"
4) "stu.level.2"
5) "stu.level.3"
6) "stu.name.1"
redis 127.0.0.1:6379> sort lst.stud by stu.level.[i] desc get stu.level.[/i] get stu.name.*
1) "3"
2) "admin"
3) "2"
4) "joe"
5) "1"
6) "jim"
redis 127.0.0.1:6379> sort lst.stud by stu.level.[i] asc get stu.name.[/i]
1) "jim"
2) "joe"
3) "admin"sort虽然很“厉害”,但尽量不要让redis服务器来sort大量的数据。可以通过设定阀值减少要sort的数据,或把排序操作向前移,在web服务器或各个应用上来sort。 查看全部
总结redis中跟key相关的常用函数
1)keys
语法:keys pattern
解释:查找所有匹配指定模式pattern的key
[root@cjlx ~]# redis-cli   
redis 127.0.0.1:6379> keys * #所有key
1) "score"
2) "stu"
3) "score1"
4) "dest"
5) "lst.user"
6) "lst.tect"
redis 127.0.0.1:6379> keys scor?
1) "score"
redis 127.0.0.1:6379> keys scor[ee1]
1) "score"
2)randomkey
语法:randomkey 
解释:返回一个随机key
redis 127.0.0.1:6379> randomkey  
"score"
redis 127.0.0.1:6379> randomkey
"list.user"
3)exists
语法:exists key
解释:判断一个key是否存在
redis 127.0.0.1:6379> exists score  #key存在 返回1  
(integer) 1
redis 127.0.0.1:6379> exists scorefda #key不存在 返回0
(integer) 0
4)type
语法:type key
解释:返回key所存储的值类型,返回值:none [key不存在],string,list ,set, zset和hash
redis 127.0.0.1:6379> type score  
zset
redis 127.0.0.1:6379> type lst.user
list
5)expire
语法:expire key seconds
解释:设置key的生存时间,单位是秒,当key过期时,会被自动删除
redis 127.0.0.1:6379> expire dest 30  
(integer) 1
redis 127.0.0.1:6379> expire dest1 30 # key不存在
(integer) 0
6)ttl
语法: ttl key
解释:得到key能存活时间,如果key不存在或没有设置生存时间时,返回-1
redis 127.0.0.1:6379> expire diff 100  
(integer) 1
redis 127.0.0.1:6379> ttl diff
(integer) 94
redis 127.0.0.1:6379> ttl diff
(integer) 92

7)persist
语法:persist key
解释:移除给定key的生存时间
redis 127.0.0.1:6379> ttl diff  
(integer) 28
redis 127.0.0.1:6379> persist diff
(integer) 1
redis 127.0.0.1:6379> ttl diff
(integer) -1
8)rename
语法:rename key newkey
解释:将key改名为newkey
redis 127.0.0.1:6379> smembers diff  
1) "zhangsan01"
redis 127.0.0.1:6379> rename diff diff01
OK
redis 127.0.0.1:6379> smembers diff
(empty list or set)
redis 127.0.0.1:6379> smembers diff01
1) "zhangsan01"
redis 127.0.0.1:6379> rename diff diff01
(error) ERR no such key
注意:当key和newkey相同或key不存在时,返回错误;当newkey已存在时,rename将覆盖旧值。
 
9)renamenx
语法:renamenx key newkey
解释:当且仅当newkey不存在时,改名key
redis 127.0.0.1:6379> renamenx diff01 stu  #stu存在  
(integer) 0
redis 127.0.0.1:6379> renamenx diff01 diff #diff不存在
(integer) 1
10)del
语法:del key [key ...]
解释:删除一个或多个key
redis 127.0.0.1:6379> del score1  
(integer) 1
redis 127.0.0.1:6379> del union diff aa #key aa 不存在
(integer) 2
11)move
语法:move key db
解释:将key移动到指定db
redis 127.0.0.1:6379> smembers stu #默认0  
1) "zhangsan01"
2) "wangwu"
redis 127.0.0.1:6379> move stu 1 #移动到 1
(integer) 1
redis 127.0.0.1:6379> smembers stu
(empty list or set)
redis 127.0.0.1:6379> select 1 #选择db 1
OK
redis 127.0.0.1:6379[1]> smembers stu
1) "zhangsan01"
2) "wangwu"
12)sort
语法:sort key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]
解释:返回或保持给定列表,集合,有序集合key中经过排序的元素
redis 127.0.0.1:6379> sort lst.tech limit 0 2 alpha desc #按字符集排序  
1) "tec06"
2) "tec05"
redis 127.0.0.1:6379> sort lst.stud
1) "1"
2) "2"
3) "3"
redis 127.0.0.1:6379> sort lst.stud desc
1) "3"
2) "2"
3) "1"
redis 127.0.0.1:6379> keys stu.*
1) "stu.name.2"
2) "stu.name.3"
3) "stu.level.1"
4) "stu.level.2"
5) "stu.level.3"
6) "stu.name.1"
redis 127.0.0.1:6379> sort lst.stud by stu.level.[i] desc get stu.level.[/i] get stu.name.*
1) "3"
2) "admin"
3) "2"
4) "joe"
5) "1"
6) "jim"
redis 127.0.0.1:6379> sort lst.stud by stu.level.[i] asc get stu.name.[/i]
1) "jim"
2) "joe"
3) "admin"
sort虽然很“厉害”,但尽量不要让redis服务器来sort大量的数据。可以通过设定阀值减少要sort的数据,或把排序操作向前移,在web服务器或各个应用上来sort。

启动apache报错 [warn] module php5_module is already loaded, skipping

开源技术采菊篱下 回复了问题 • 1 人关注 • 1 个回复 • 1160 次浏览 • 2015-06-13 12:02 • 来自相关话题

Centos下php5.4 编译常见错误解决

编程语言OpenSkill 发表了文章 • 0 个评论 • 681 次浏览 • 2015-06-12 17:45 • 来自相关话题

configure: error: xml2-config not found. Please check your libxml2 installation.
yum install libxml2-devel

configure: error: Cannot find OpenSSL’s
yum install openssl-devel

configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
yum install curl-devel

configure: error: libjpeg.(a|so) not found
yum install libjpeg-devel

configure: error: libpng.(a|so) not found.
yum install libpng-devel

configure: error: libXpm.(a|so) not found.
yum install libXpm-devel

configure: error: freetype.h not found.
yum install freetype-devel

configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
yum install libc-client-devel

configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install libmcrypt-devel

configure: error: Please reinstall libmhash – I cannot find mhash.h
yum install mhash-devel

configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!
yum install mysql-devel

configure: error: Please reinstall ming distribution. libming.(a|so) not found
[list]
[*]temp remove the config for ‘–with-ming=/opt/ming/’[/*]
[/list]
configure: error: Cannot find pspell
yum install pspell-devel

configure: error: cannot find mm library
Download from http://www.ossp.org/pkg/lib/mm/
wget ftp://ftp.ossp.org/pkg/lib/mm/mm-1.4.2.tar.gz
Extract it: tar -zxvf mm-1.4.2.tar.gz
./configure
make
make install

configure: error: Cannot find libtidy
yum install libtidy-devel
yum install libtidy
change path at configure: ‘–with-tidy=/usr’

configure: error: not found. Please reinstall the expat distribution.
yum install expat-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
yum install libxslt-devel 查看全部
configure: error: xml2-config not found. Please check your libxml2 installation.
yum install libxml2-devel

configure: error: Cannot find OpenSSL’s
yum install openssl-devel

configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
yum install curl-devel

configure: error: libjpeg.(a|so) not found
yum install libjpeg-devel

configure: error: libpng.(a|so) not found.
yum install libpng-devel

configure: error: libXpm.(a|so) not found.
yum install libXpm-devel

configure: error: freetype.h not found.
yum install freetype-devel

configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
yum install libc-client-devel

configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install libmcrypt-devel

configure: error: Please reinstall libmhash – I cannot find mhash.h
yum install mhash-devel

configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!
yum install mysql-devel

configure: error: Please reinstall ming distribution. libming.(a|so) not found
[list]
[*]temp remove the config for ‘–with-ming=/opt/ming/’[/*]
[/list]
configure: error: Cannot find pspell
yum install pspell-devel

configure: error: cannot find mm library
Download from http://www.ossp.org/pkg/lib/mm/
wget ftp://ftp.ossp.org/pkg/lib/mm/mm-1.4.2.tar.gz
Extract it: tar -zxvf mm-1.4.2.tar.gz
./configure
make
make install

configure: error: Cannot find libtidy
yum install libtidy-devel
yum install libtidy
change path at configure: ‘–with-tidy=/usr’

configure: error: not found. Please reinstall the expat distribution.
yum install expat-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
yum install libxslt-devel

PHP随机生成token

编程语言OpenSkill 发表了文章 • 0 个评论 • 790 次浏览 • 2015-06-12 16:33 • 来自相关话题

使用token的方式,可以控制用户在这个时间内的权限,代码如下:<?php
function genToken( $len = 32, $md5 = true ) {
# Seed random number generator
# Only needed for PHP versions prior to 4.2
mt_srand( (double)microtime()*1000000 );
# Array of characters, adjust as desired
$chars = array(
'Q', '@', '8', 'y', '%', '^', '5', 'Z', '(', 'G', '_', 'O', '`',
'S', '-', 'N', '<', 'D', '{', '}', '[', ']', 'h', ';', 'W', '.',
'/', '|', ':', '1', 'E', 'L', '4', '&', '6', '7', '#', '9', 'a',
'A', 'b', 'B', '~', 'C', 'd', '>', 'e', '2', 'f', 'P', 'g', ')',
'?', 'H', 'i', 'X', 'U', 'J', 'k', 'r', 'l', '3', 't', 'M', 'n',
'=', 'o', '+', 'p', 'F', 'q', '!', 'K', 'R', 's', 'c', 'm', 'T',
'v', 'j', 'u', 'V', 'w', ',', 'x', 'I', '$', 'Y', 'z', '*'
);
# Array indice friendly number of chars;
$numChars = count($chars) - 1; $token = '';
# Create random token at the specified length
for ( $i=0; $i<$len; $i++ )
$token .= $chars[ mt_rand(0, $numChars) ];
# Should token be run through md5?
if ( $md5 ) {
# Number of 32 char chunks
$chunks = ceil( strlen($token) / 32 ); $md5token = '';
# Run each chunk through md5
for ( $i=1; $i<=$chunks; $i++ )
$md5token .= md5( substr($token, $i * 32 - 32, 32) );
# Trim the token
$token = substr($md5token, 0, $len);
} return $token;
}
//生成的32位随机数
echo genToken()
?> 查看全部
使用token的方式,可以控制用户在这个时间内的权限,代码如下:
<?php
function genToken( $len = 32, $md5 = true ) {
# Seed random number generator
# Only needed for PHP versions prior to 4.2
mt_srand( (double)microtime()*1000000 );
# Array of characters, adjust as desired
$chars = array(
'Q', '@', '8', 'y', '%', '^', '5', 'Z', '(', 'G', '_', 'O', '`',
'S', '-', 'N', '<', 'D', '{', '}', '[', ']', 'h', ';', 'W', '.',
'/', '|', ':', '1', 'E', 'L', '4', '&', '6', '7', '#', '9', 'a',
'A', 'b', 'B', '~', 'C', 'd', '>', 'e', '2', 'f', 'P', 'g', ')',
'?', 'H', 'i', 'X', 'U', 'J', 'k', 'r', 'l', '3', 't', 'M', 'n',
'=', 'o', '+', 'p', 'F', 'q', '!', 'K', 'R', 's', 'c', 'm', 'T',
'v', 'j', 'u', 'V', 'w', ',', 'x', 'I', '$', 'Y', 'z', '*'
);
# Array indice friendly number of chars;
$numChars = count($chars) - 1; $token = '';
# Create random token at the specified length
for ( $i=0; $i<$len; $i++ )
$token .= $chars[ mt_rand(0, $numChars) ];
# Should token be run through md5?
if ( $md5 ) {
# Number of 32 char chunks
$chunks = ceil( strlen($token) / 32 ); $md5token = '';
# Run each chunk through md5
for ( $i=1; $i<=$chunks; $i++ )
$md5token .= md5( substr($token, $i * 32 - 32, 32) );
# Trim the token
$token = substr($md5token, 0, $len);
} return $token;
}
//生成的32位随机数
echo genToken()
?>