Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing PHP Zip Extension

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

like image 591
Ubunfu Avatar asked Sep 12 '13 21:09

Ubunfu


People also ask

What is PHP zip?

ZIP is an archive file format that supports lossless data compression. A ZIP file may contain one or more files or directories that may have been compressed. The PHP ZipArchive class can be used to zipping and unzipping. It might be need to install the class if it is not present.


2 Answers

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.

like image 196
Ajeet Shah Avatar answered Sep 30 '22 05:09

Ajeet Shah


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.

like image 43
cweiske Avatar answered Sep 30 '22 07:09

cweiske