工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.51099.com 注册 | 登陆
浏览模式: 标准 | 列表2013年01月的文章

unpack() [function.unpack]: Type v: not enough input, need 2

PHPZip.class.php报unpack() [function.unpack]: Type v: not enough input, need 2, have 0 in解决办法

正常的在win环境下是没问题的,但是在linux环境下就会报unpack() [function.unpack]: Type v: not enough input, need 2, have 0 in错误,解决办法就是

在类文件中找到 if($bytes == 0x504b0506) 改成 if(substr(dechex($bytes),-8,8) == '504b0506')  就是这样。

 

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

$bytes=($bytes << 8) | ord($byte);
改为
$bytes=(($bytes << 40)>>32)| ord($byte);

php5 install FAQ

1.
Error: Configure: error: xml2-config not found. Please check your libxml2 installation.
Fix: yum install libxml2 libxml2-devel
# aptitude install libxml2-dev (For ubuntu)

2.
Error: configure: error: Cannot find OpenSSL’s
Fix: yum install openssl openssl-devel

3.
Error: Configure: error: Please reinstall the BZip2 distribution
Fix: yum install bzip2 bzip2-devel

 

4.
Error: Configure: error: Please reinstall the libcurl distribution -easy.h should be in /include/curl/
Fix: yum install curl curl-devel (For Redhat & Fedora)
# install libcurl4-gnutls-dev (For Ubuntu)

5.
Error: Configure: error: libjpeg.(also) not found.
Fix: yum -y install gd
yum -y install gd-devel
yum install libjpeg libjpeg-devel

6.
Error: Configure: error: libpng.(also) not found.
Fix: yum install libpng libpng-devel
#apt-get install libpng12-dev

7) Configure: error: freetype.h not found.
Solutions :
yum install freetype-devel

8) Configure: error: Unable to locate gmp.h

Solutions :
yum install gmp-devel

9) Configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!

Solutions :
yum install mysql-devel (For Redhat & Fedora)

# apt-get install libmysql++-dev (For Ubuntu)

10) Configure: error: Please reinstall the ncurses distribution

Solutions :
yum install ncurses ncurses-devel

11) Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

Solutions :
yum install unixODBC-devel

12. --with-pspell=shared
Error: Configure: error: Cannot find pspell
Fix: yum install pspell-devel

13) --with-mcrypt=shared
Error: configure: error: mcrypt.h not found. Please reinstall libmcrypt.
Fix: yum install libmcrypt-devel

# apt-get install libmcrypt-dev

14) Configure: error: snmp.h not found. Check your SNMP installation.

Solutions :

yum install net-snmp net-snmp-devel

15)开启LDAP服务还需要
yum -y install openldap-devel openldap-servers openldap-clients

16)configure: error: No curses/termcap library found
网上有的说法是:
–with-named-curses-libs=/usr/lib/libncursesw.so.5
其实是不对的,虽然能解决configure的错误,但是make的时候会提示错误,正确的做法应该是
yum -y install ncurses-devel (for redhat)
apt-get install libncurses5-dev(for debian)

17)configure: error: cannot find output from lex; giving up
yum -y install flex

18)configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
yum -y install zlib-devel openssl-devel
debian:apt-get install zlib1g-dev

19)configure: error: libXpm.(a|so) not found.
apt-get install libxpm-dev

20) configure: error: Could not find pcre.h in /usr
Fix: yum install pcre-devel

21) configure: error: Could not find libpcre.(a|so) in /usr
Fix: cp /usr/lib/libpcre.a /usr/libpcre.a
Refer: http://bugs.php.net/bug.php?id=1647

22. --with-db4
Error: configure: error: DBA: Could not find necessary header file(s).
Fix: yum install gdbm-devel db4-devel
Error: configure: error: Header contains different version
Fix: --with-libdir=lib (--libdir=/usr/lib64, which is wrong)
Refer: http://bugs.php.net/bug.php?id=40707

23) configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing
Fix: yum install libc-client-devel

24. --enable-intl=shared
Error: configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.

25.--with-ldap=shared
Error: configure: error: Cannot find ldap.h
Fix: yum install openldap-devel
Error: configure: error: Cannot find ldap libraries in /usr/lib64.

26.--with-readline=shared
Error: configure: error: Please reinstall readline - I cannot find readline.h
Fix: yum install readline-devel

27.--with-tidy=shared
Error: configure: error: Cannot find libtidy
Fix: yum install libtidy-devel

28.--with-xsl=shared
Error: configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
Fix: yum install libxslt-devel

CentOS x64 里php 源码编译出错参见情况及解决办法

yum install libxml2-devel.x86_64

configure: error: Cannot find OpenSSL’s

yum install openssl-devel.x86_64

configure: error: Could not find pcre.h in /usr/local

yum install pcre-devel.x86_64

configure: error: Could not find pcre.h in /usr/local

"--with-pcre-regex=/usr/include" \

configure: error: Could not find libpcre.(a|so) in /usr/include

"--with-pcre-regex=/usr" \

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

yum install curl-devel.x86_64

configure: error: libjpeg.(a|so) not found.

yum install libjpeg-devel.x86_64

configure: error: libpng.(a|so) not found.

yum install libpng-devel.x86_64

configure: error: freetype.h not found.

yum install freetype-devel.x86_64

configure: error: Please reinstall the iconv library.

"--with-iconv" \

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

yum install libmcrypt.x86_64 libmcrypt-devel.x86_64

configure: error: Please reinstall libmhash – I cannot find mhash.h

yum install mhash.x86_64 mhash-devel.x86_64

Note that the MySQL client library is not bundled anymore!

yum install php-mysql.x86_64 mysql-devel.x86_64

configure: error: Please reinstall the BZip2 distribution

yum install bzip2-devel.x86_64

configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
DISABLE IMAP
configure: error: Cannot find pspell

yum install aspell-devel.x86_64

configure: error: Cannot find libtidy

yum install libtidy.x86_64 libtidy-devel.x86_64

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

yum install libxslt.x86_64 libxslt-devel.x86_64

collect2: ld returned 1 exit status

yum install glibc-utils.x86_64 libtool-ltdl-devel.x86_64

Step by step to guide PHP Compile

Step 1: Update & Install Development Tools & Libraries

yum update yum group install "Development Tools" yum group install "Development Libraries"

yum安装apache+php+mysql等

1. 安装Apahce, PHP, Mysql, 以及php连接mysql库组件。
yum -y install httpd php mysql mysql-server php-mysql 

2. 配置开机启动服务
/sbin/chkconfig httpd on [设置apache服务器httpd服务开机启动]
/sbin/chkconfig --add mysqld [在服务清单中添加mysql服务]
/sbin/chkconfig mysqld on [设置mysql服务开机启动]

/sbin/service httpd start [启动httpd服务,与开机启动无关]
/sbin/service mysqld start [启动mysql服务,与开机无关]

3.设置 mysql数据库root帐号密码。
mysqladmin -u root password 'newpassword' [引号内填密码]

4. 让mysql数据库更安全
mysql -u root -p [此时会要求你输入刚刚设置的密码,输入后回车即可]

mysql> DROP DATABASE test; [删除test数据库]
mysql> DELETE FROM mysql.user WHERE user = ''; [删除匿名帐户]
mysql> FLUSH PRIVILEGES; [重载权限]

5. 按照以上的安装方式, 配置出来的默认站点目录为/var/www/html/新建一个php脚本:
phpinfo();
?>

6. 新建一个数据库,添加一个数据库用户,设置用户权限。写个php脚本测试一下数据库连接吧。
mysql> CREATE DATABASE my_db; 
mysql> GRANT ALL PRIVILEGES ON my_db.* TO 'user'@'localhost' IDENTIFIED BY 'password'; 



//安 装apache扩展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
//安装php的扩展
yum install php-gd
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
// 安装mysql扩展
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

7, 如果命令行没有phpize,运行以下命令 
yum -y install php-devel

8,安装pdo
pecl install pdo
PHP_PDO_SHARED=1 pecl install pdo_mysql

 

pecl install PDO_SQLITE


9, 安装memcache
yum -y install php-pecl-memcache

10, 安装php-eaccelerator
yum install php-eaccelerator.i686



CentOS 5.x 系统下使用yum 升级php到5.2.x 最方便方法 
近期使用testlink 1.82 ,提及php需要升级到5.2以上,而centos 5.x目前提供php版本为5.1.6,
通过以下方法升级PHP到5.2比较方便,现推荐给大家。

先将以下地址导入。

# rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

# vi /etc/yum.repos.d/CentOS-Base.repo 增加下面信息

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

执行命令,自动升级。

yum update php -y
yum install libmcrypt -y

checking for re2c... no

checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.


http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download

tar打包split分割分解拆分大包文件

有时候远程下载tar包的时候,由于包太大,失去连接时,需要重新下载非常郁闷。
这时候使用split分割分解拆分大包文件,然后单个下载下文件就OK。

在Linux下使用 tar 命令来将文件打包并压缩是很通常的用法了。可是Linux的文件系统对文件大小有限制,也就是说一个文件最大不能超过2G,如果压缩包的的内容很大,最后 的结果就会超过2G,那么该怎么办呢?又或者压缩包希望通过光盘来进行备份,而每张光盘的容量只有700M,那么该如何存储呢?解决的办法就是将最后的压 缩包按照指定大小进行分割,这就需要用到split命令了。

举例说明:
要将目录logs打包压缩并分割成多个1M的文件,可以用下面的命令:
tar cjf - logs/ |split -b 1m - logs.tar.bz2.
完成后会产生下列文件:
logs.tar.bz2.aa, logs.tar.bz2.ab, logs.tar.bz2.ac
要解压的时候只要执行下面的命令就可以了:
cat logs.tar.bz2.a* | tar xj

再举例:
要将文件test.pdf分包压缩成500 bytes的文件:
tar czf - test.pdf | split -b 500 - test.tar.gz
最后要提醒但是那两个"-"不要漏了,那是tar的ouput和split的input的参数。

这里对命令做一些讲解。 
压缩和分割命令行中红色部分的为命令对应的I/O文件名参数,其中-表示标准输入或输出。那么结合上面的例子,tar命令表示的意思就是将logs目录压缩,生成的结果直接输送到标准输出上;而split命令表示从标准输入获得文件内容进行分割,结果文件前缀为logs.tar.bz2.。二者再通过管道将各自的标准输入输出对接起来。 

这里再解释一下split命令的参数含义: 
-b SIZE 指定每个文件的大小,其单位可以为b(512字节)、k(1K)、m(1M) 
-d 使用数字而不是字母作为后缀名 
-a X 指定后缀名的长度,默认为2位 

这样上面的命令就可以变化为: 
tar cjf - logs/ |split -b 1m -d -a 1- logs.tar.bz2.

tar备份

增量备份

  1.首先创建完全备份:tar -czvf -g zeng aa.tar.gz /var

  待/var中的数据变化后

  2.再做增量备份: tar -czvf -g zeng aa.tar.gz.1 /var

  差异备份

  1. find /var -mtime -1 -print> filelist

  产生要备份的档案的列表-1表示是一天的时间

  2.tar -czv -T filelist -f /backup.tar.gz

  依据文件列表进行备份. -T选项可以指定包含要备份的档案的列表

二、还原

tar -zxvf 备份文件.tar.gz -C /

参数x是告诉tar程序解压缩备份文件。 -C 参数是指定tar程序解压缩到的目录。

使用 Crash 工具分析 Linux dump 文件