我想实现的
我将在PHP Web应用程序开发中使用PhpSpreadsheet,我试图配置要在服务器上启用PhpSpreadsheet所必需的PHP Zip扩展。我尝试了两种方法,但设置不好,所以我想告诉我解决方案和其他要检查的内容。
我尝试的第一种方法
在终端执行以下操作
# yum install php71-php-pecl-zip.x86_64
# cp /etc/opt/remi/php71/php.d/40-zip.ini /etc/php.d/40-zip.ini
# systemctl stop httpd.service
# systemctl start httpd.service
从Web浏览器使用PhpSpreadsheet执行处理时,发生错误
/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php: 71
Class 'ZipArchive' not found
我确认在终端上启用了Zip扩展名,但是我不知道原因。
# php --info
Additional. Ini files parsed =>
·
·
/etc/php.d/40-zip.ini
·
·
zip
Zip => enabled
Zip version => 1.15.2
Libzip headers version => 1.3.2
Libzip library version => 1.5.1
zlib
ZLib Support => enabled
Stream Wrapper => compress.zlib: / /
Stream Filter => zlib.inflate, zlib.deflate
Compiled Version => 1.2.7
Linked Version => 1.2.7
Directive => Local Value => Master Value
zlib.output_compression => Off => Off
zlib.output_compression_level => -1 => -1
zlib.output_handler => no value => no value
# php vendor / phpoffice / phpspreadsheet / samples / index.php
Requirement check:
PHP 5.6.0 ... passed
PHP extension XML ... passed
PHP extension xmlwriter ... passed
PHP extension mbstring ... passed
PHP extension ZipArchive ... passed
PHP extension GD (optional) ... passed
PHP extension dom (optional) ... passed
我尝试的第二种方法
取消1st的设置后(卸载软件包,删除复制的文件)在终端上执行以下操作
# yum install php71-php-devel.x86_64
# yum install zlib-devel.x86_64
# pecl install zip
第三个命令中发生以下错误
# pecl install zip
No releases available for package "pecl.php.net/zip"
install failed
由于上述错误,下载文件并执行phpize不会再次出现错误...
# wget http://pecl.php.net/get/zip-1.15.2.tgz
# phpize
Can not find PHP headers in /usr/include/php
The php-devel package is required for use of this command.
我不明白为什么在pecl install zip和中会发生错误phpize。
附加信息(固件/工具版本等)
操作系统:Red Hat Enterprise Linux Server 7.4(Maipo)
PHP:7.1.14
倚天杖