Using zip files is a common practice for web. Zip archives are very useful as they are supported by all major operating systems and don’t require any special software. XP and Vista have the embedded support of this file format, you won’t also have problems opening these files in Linux. You can also work with these files in PHP. in order to do this, you should have ZZIPlib installed – it allows the easiest way to work with zip archives.
In this article I will tell you how to add zip file support for your PHP installation. As usually, we will need root access to our server with PHP compiled from source files.
In this article I will describe how to add zip support to PHP5 as it is installed at most servers at the moment. My OS is CentOS, but the installation should not differ from other operating systems, it’s easy enough to add zip functions.
First of all we need to ensure we have zlib installed. Run rpm -qa | grep zlib to check whether it is already installed and install it using yum if it is not present in the list created by the output of previous command. yum install zlib* should install everything related to zlib – that’s what we need to run zip.
Then run phpinfo() and copy the configure line you have. It should look like: ./configure –with-apxs –with-curl –with-curl-dir=/usr/local/lib –with-gd –with-gd-dir=/usr/local –with-gettext –with-jpeg-dir=/usr/local/lib –with-kerberos, etc. Then you need to add –enable-zip to this line.
Then you need to go to the directory where PHP source files are located. If you server has Directadmin installed, you should go to /usr/local/directadmin/customapache – your PHP files should be located there. Then change directory to the one with PHP source files and run the configuree command with –enable-zip added. Then – make and make install as usually.
After this all you need is to reboot apache. Your PHP installation should now support zip functions.