Installing PHP Zip Extension

て烟熏妆下的殇ゞ 提交于 2019-11-26 18:11:27

问题


I'm attempting to install the PHP Zip extension.

My server does not have external internet access, so I downloaded it myself from PECL: http://pecl.php.net/package/zip. I chose 1.10.2, the latest "stable" release, and transferred it to my server.

I ran:

pear install zip-1.10.2.tgz

and added

extension=zip.so

to php.ini as instructed. I can see that zip.so was created and placed in the right extension_dir folder as well. I restarted apache and then checked to see if it was loaded by running:

php -m

Despite all of this, "zip" is still not in that list.

Am I missing a step or doing something wrong? I thought this should be really simple, and I'm starting to feel pretty dumb, haha.

Other probably important stuff:

CentOS Apache 2.2.3 PHP 5.2.16


回答1:


You may have several php.ini files, one for CLI and one for apache. Run php --ini to see where the CLI ini location is.




回答2:


This is how I installed it on my machine (ubuntu):

php 7:

sudo apt-get install php7.0-zip

php 5:

sudo apt-get install php5-zip

Edit:
Make sure to restart your server afterwards.

sudo /etc/init.d/apache2 restart or sudo service nginx restart

PS: If you are using centOS, please check above cweiske's answer
But if you are using a Debian derivated OS, this solution should help you installing php zip extension.




回答3:


1 Step - Install a required extension

sudo apt-get install libz-dev -y

2 Step - Install the PHP extension

pecl install zlib zip

3 Step - Restart your Apache

sudo /etc/init.d/apache2 restart

If does not work you can check if the zip.ini is called in your phpinfo, to check if the zip.so was included.




回答4:


Simply use sudo yum install php-zip




回答5:


If you use php5.6 then execute this:

sudo apt-get install php5.6-zip




回答6:


if sudo apt-get install php5.6-zip does not work, try sudo apt-get update and then try sudo apt-get install php5.6-zip




回答7:


for PHP 7.3 / Ubuntu

sudo apt install php7.3-zip


来源:https://stackoverflow.com/questions/18774568/installing-php-zip-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!