(gs):Install Zip for PHP 5
- This page was last modified on March 24, 2012, at 12:36.
From (mt) Community Wiki
Results
You will install the Zip utility for PHP 5 on your (gs) Grid-Service.
This is not supported by (mt) Media Temple. Also, it will be your responsibility to check for important security patches and updates for this extension. You should reinstall or update the extension once updates are available. Otherwise, your server may become vulnerable as your installed software becomes more and more outdated over time.
Instructions
- Log into your (gs) Grid-Service with SSH.
-
Automatically set your site number variable and current PHP path for later use:
export SITEID=`pwd | awk -F\/ '{ print $3 }'`If your site uses PHP 5.2.17:
export PHPPATH=`php5 -i | grep "Configure Command" | perl -pe "s/.*'.\/configure'\s*?'--prefix\=(.*?)'.*/\1/"`
If your site uses PHP 5.3.10:
export PHPPATH=`php-latest -i | grep "Configure Command" | perl -pe "s/.*'.\/configure'\s*?'--prefix\=(.*?)'.*/\1/"`
To verify and/or change what version of PHP is being used by your website, please visit the following KnowledgeBase link: How can I specify the PHP version on the (gs) Grid-Service?
-
Make the library folder for Zip:
mkdir -p /home/$SITEID/data/lib/php
-
Set up a temporary folder for the Zip download:
mkdir ~/zip
-
Enter your temporary folder:
cd ~/zip
-
Download and decompress the Zip module (you will see a download bar):
wget http://pecl.php.net/get/zip
tar -zxvf zip
-
Move into the zip directory (note: this directory path may change with later versions of zip):
cd zip-1.10.2/
-
Install Zip:
$PHPPATH/bin/phpize
./configure --with-php-config=$PHPPATH/bin/php-config --enable-zip
make
-
Copy the compiled file to the lib folder we created previously:
cp modules/zip.so /home/$SITEID/data/lib/php/
-
Now we just need to tell Apache where to find the module. You can add the line of code to your existing php.ini file, or you can copy the sample file first, then add the line.
If you need to copy the sample php.ini file, run this command (SKIP if you already have one):
cp /home/$SITEID/etc/php.ini.sample /home/$SITEID/etc/php.ini
Add the necessary directives to your php.ini file:
echo -e "\n; Zip for PHP 5\nextension_dir=/home/$SITEID/data/lib/php\nextension=zip.so\n" >> /home/$SITEID/etc/php.ini
Or, alternatively, open the php.ini file for editing:
vi /home/$SITEID/etc/php.ini
vi tip: Press "i" to enter "insert mode" so you can type and copy/paste. Press "Esc" to exit "insert mode" when you are done modifying the file. Type ":wq" to save and quit.
Add the following lines to your php.ini (be sure to replace 00000 with your site number):
php.ini; Zip for PHP 5 extension_dir=/home/00000/data/lib/php extension=zip.so
That's it! You should now be able to use Zip on your domains that are running PHP 5. You can test this by viewing your PHP 5 (gs):Phpinfo.php page. You should see a section for zip, and zip will also be listed in the "Registered PHP Streams" row.