I will use PhpSpreadsheet in a PHP web application development, I am trying to configure PHP Zip extension necessary for PhpSpreadsheet to be enabled on the server. I tried two methods, but I could not set it well, so I would like you to tell me the solution and other things to check.
Execute the following at the terminal
# 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
When executing processing using PhpSpreadsheet from the Web browser, an error occurred
/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php: 71
Class 'ZipArchive' not found
I confirmed that the Zip extension is enabled at the terminal, but I do not know the cause.
# 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
After canceling the setting of 1st (uninstall package, delete the copied file) Execute the following at the terminal
# yum install php71-php-devel.x86_64
# yum install zlib-devel.x86_64
# pecl install zip
The following error occurred in the third command
# pecl install zip
No releases available for package "pecl.php.net/zip"
install failed
Due to the error above, downloading the file and executing phpize
will not proceed with an error again ...
# 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.
I did not understand why errors occurred in pecl install zip
andphpize
.
OS: Red Hat Enterprise Linux Server release 7.4 (Maipo)
PHP: 7.1.14
first, run this command
sudo yum install php-zip
after change php.ini file
extension=zip.so
now run this command.
sudo service httpd restart
sudo service php-fpm restart
it's working for me in cent os on amazon server.