Unzip .zip or .tar.bz2 files on the server

When setting up new installations of Joomla! on my web server I have a choice of using my hosting control panel or uploading via FTP. However, my hosting company has recently updated to Joomla! 1.5 as standard and the site I am currently developing requires a component (NeoRecruit) which is currently only compatible with Joomla 1.0.xx .

In this situation I would customarily unzip the Joomla! files locally and then upload via FTP. However, the upload process using FTP is quite time-consuming. I was fairly sure it was possible to FTP the zipped files to my server, and then unzip them in situ. I simply hadn’t got around to investing the time to find out how. A little digging around on the net revealed the following procedure:

Upload a zip file using ftp. Once uploaded, you can unzip the file by following these steps :
1. Create a file called unzip.php as follows and upload to the same folder as the archive.
2. Copy/paste the following content into unzip.php :
<? exec(“unzip myfile.zip”); ?>
3. Replace myfile.zip with the name of your file
4. Open yourdomain.com/path_to/unzip.php in a browser
The .zip file will be extracted into the same folder as the archive.

Joomla! offer files in a variety of formats including .zip, but the smallest was in a .tar.bz2 file format. I could have used SSH to decompress the file on the server, but I preferred to use a version of the php solution outlined above. I replaced “unzip myfile.zip” with “tar xvjf filename.tar.bz2″and the files were untarred to the current directory.
Apparently the syntax of the code is:
tar – Tape ARchiver
And the options:
x – extract
v – verbose output (lists all files as they are extracted)
j – deal with bzipped file (replace j with z if its a .zip file)
f – read from a file, rather than a tape device

The entire set up took a matter of minutes.

Leave a Reply

Your email address will not be published. Required fields are marked *