Fatal error: Class ‘ZipArchive’ not found的解决方法

Linux 下PHP添加zip.so
2011年11月22日 星期二 16:13

1. 下载zip.so包

[root@localhost phpinstall]# wget http://pecl.php.net/get/zip-1.10.2.tgz

--2011-10-0919:44:36--  http://pecl.php.net/get/zip-1.10.2.tgz

Resolvingpecl.php.net... 76.75.200.106

Connecting topecl.php.net|76.75.200.106|:80... connected.

HTTP request sent,awaiting response... 200 OK

Length: 236912(231K) [application/octet-stream]

Saving to:`zip-1.10.2.tgz'

100%[======================================>]236,912     30.5K/s   in 7.6s   

 2011-10-09 19:44:44(30.4 KB/s) - `zip-1.10.2.tgz' saved [236912/236912]

 

2.  解压tgz包

[root@localhost phpinstall]#tar -zxvf zip-1.10.2.tgz

[root@localhost phpinstall]# cd zip-1.10.2

[root@localhost zip-1.10.2]# ls

config.m4  config.w32 CREDITS  examples  lib php_zip.c  php_zip.h  tests zip_stream.c

 

3.  编译安装源文件   自己安装的PHP 路径    [root@house zip-1.10.2]# /usr/local/php/bin/phpize 

[root@localhost zip-1.10.2]# /usr/bin/phpize   

Configuring for:

PHP ApiVersion:         20041225

Zend Module ApiNo:      20060613

Zend Extension ApiNo:   220060519

[root@localhost zip-1.10.2]# ./configure --with-php-config=/usr/bin/php-config

checking for egrep... grep -E

checking for a sed that does not truncate output... /bin/sed

...

configure: creating ./config.status

config.status: creating config.h

[root@localhost zip-1.10.2]# make

/bin/sh/u01/phpinstall/zip-1.10.2/libtool --mode=compile cc  -I. -

....

Build complete.

Don't forget to run 'make test'.

[root@localhost zip-1.10.2]# make install

Installing sharedextensions:     /usr/lib64/php/modules/

 

4.  修改php.ini,增加zip.so模块,重启apache

[root@localhost zip-1.10.2]# vi /etc/php.ini 

 extension=zip.so

[root@localhost zip-1.10.2]# /etc/init.d/httpd restart

Stopping httpd:                                           [  OK  ]

Starting httpd:                                           [  OK  ]

 

5. 验证zip模块

[root@fast /]# php -m |grep zip

zip

[root@fast /]#

 

 

 

Fatal error: Class ‘ZipArchive’ not found的解决方法  

2011-08-02 23:53:51|  分类: 默认分类 |字号 订阅

出现这个错误说明是程序在调用’ZipArchive’ 这个类的时候没有成功,原因是由于在安装php的时候没有增加php zip的支持(非zlib)。

在Windows下的解决办法是

1、在php.ini文件中,将extension=php_zip.dll前面的分号“;”去除,然后同样在php.ini文件中,将 zlib.output_compression = Off 改为 zlib.output_compression = On ;

2。把php.ini拷到c:/window目录下

3、重启Apache服务器。

在Unix/Linux下的解决办法

1、在Linux下没有php_zip.dll这个文件(有也不会起作用的),所以需要重新编译一下php的zip模块。具体安装方法如下:

cd /usr/src
wget http://pecl.php.net/get/zip
tar -zxvf zip
cd zip-1.x.x
phpize
./configure
make
sudo make instal

其中, 在最后使用make install命令的时候,可能需要用到root的权限,所以建议使用sudo来运行。安装完之后,屏幕上会提示zip.so的位置。然后将其记录下来, 如:/usr/local/lib/php/extensions/zip.so。

2、使用root权限修改php.ini(通常可能会在/usr/local/lib/文件夹下,不过视当初安装php而定,可以通过 phpinfo()来查看):

增加extension = /usr/local/lib/php/extensions/zip.so,然后同样在php.ini文件中,将 zlib.output_compression = Off 改为 zlib.output_compression = On ;

3、最后别忘了重启一下Apache:apachectl restart;

这个针对php的zip模块就安装完成了,能够在php中使用ZipArchive类了。

转载于:https://www.cnblogs.com/holyes/archive/2012/06/26/8f0386204938bff4c2775302cb68fd89.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值