我在使用composer在生产服务器上安装PHPOffice/PHPSpreadsheet时遇到问题。当我运行composer install
或composer update
时,我得到以下结果
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires phpoffice/phpspreadsheet ^1.19.0 -> satisfiable by phpoffice/phpspreadsheet[1.19.0].
- phpoffice/phpspreadsheet 1.19.0 requires ext-zip * -> it is missing from your system. Install or enable PHP's zip extension.
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php.ini
- /etc/php.d/20-bcmath.ini
- /etc/php.d/20-bz2.ini
- /etc/php.d/20-calendar.ini
- /etc/php.d/20-ctype.ini
- /etc/php.d/20-curl.ini
- /etc/php.d/20-dom.ini
- /etc/php.d/20-exif.ini
- /etc/php.d/20-fileinfo.ini
- /etc/php.d/20-ftp.ini
- /etc/php.d/20-gd.ini
- /etc/php.d/20-gettext.ini
- /etc/php.d/20-iconv.ini
- /etc/php.d/20-mbstring.ini
- /etc/php.d/20-mysqlnd.ini
- /etc/php.d/20-pdo.ini
- /etc/php.d/20-phar.ini
- /etc/php.d/20-posix.ini
- /etc/php.d/20-shmop.ini
- /etc/php.d/20-simplexml.ini
- /etc/php.d/20-sockets.ini
- /etc/php.d/20-sodium.ini
- /etc/php.d/20-sqlite3.ini
- /etc/php.d/20-sysvmsg.ini
- /etc/php.d/20-sysvsem.ini
- /etc/php.d/20-sysvshm.ini
- /etc/php.d/20-tokenizer.ini
- /etc/php.d/20-xml.ini
- /etc/php.d/20-xmlwriter.ini
- /etc/php.d/20-xsl.ini
- /etc/php.d/30-mysqli.ini
- /etc/php.d/30-pdo_mysql.ini
- /etc/php.d/30-pdo_sqlite.ini
- /etc/php.d/30-xmlreader.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
bash-4.2$ composer install --with-all-dependencies
[Symfony\Component\Console\Exception\RuntimeException]
The "--with-all-dependencies" option does not exist.
install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-scripts] [--no-progress] [--no-install] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>]...
我运行的是PHP8.0,当我安装它时,我安装了php-zip,当我运行php -m
时,我得到了以下列表
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
zlib
[Zend Modules]
我已经尝试了我能想到的所有方法来启用zip扩展。我甚至尝试过使用sudo yum install php-zip
重新安装它,然后尝试启用它。
我使用以下命令安装了我的PHP栈:sudo yum -y install php php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json}
在安装PHP之后,我运行php -m
,发现压缩模块没有加载。然后,我再次运行sudo yum -y php-zip
查看加载的模块,但它仍然不在那里。然后,我修改了php.ini文件并添加了extension=php
。在我运行php -v
后,我收到了这样的信息: PHP警告: PHP启动:无法加载动态库'zip‘(已尝试: /usr/lib64/php/modules/zip (/usr/lib64/php/modules/zip:无法打开共享对象文件:没有这样的文件或目录),/usr/lib64/ PHP /modules/zip.so (/usr/lib64/ PHP /modules/zip.so:无法打开共享目标文件:没有这样的文件或目录)中未知第0行PHP 8.0.12 (cli) (built: Oct 19 2021 10:34:32) ( NTS gcc x86_64 )版权所有(c) PHP Group Zend Engine v4.0.12,版权所有(c) Zend Technologies
这是我用来安装PHP8的完整命令列表。我遵循了这个网站上的说明:https://www.tecmint.com/install-php-8-on-centos/
下面是我使用的命令
sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php80
sudo yum -y install php php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json}
有谁有什么想法或想法吗?
发布于 2021-11-05 14:42:09
通过安装pecl zip模块,我终于能够加载zip扩展了。
在安装之后,我重新加载了运行php -m
的sudo yum install php-pecl-zip
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
zip
zlib
[Zend Modules]
https://stackoverflow.com/questions/69853899
复制相似问题